api - 使用 Share API v2 发布到 LinkedIn 时出现 HTTP 响应错误
问题描述
我正在尝试使用 OAuth v2 向 LinkedIn 发布共享 - 我已正确获得授权并拥有适当的访问密钥。这段代码应该在 LinkedIn 上共享一个链接,但由于某种原因它不起作用 - 我不确定为什么。任何人都可以帮忙吗?这是我的请求正文:
{
"distribution": {
"linkedInDistributionTarget": {}
},
"owner": "urn:li:person:XXXXXX",
"subject": "Test Share Subject",
"text": {
"text": "Hello !"
}
这是我的呼叫 API 共享:
publishPostLink(body : any, token : any){
this.headers = new HttpHeaders(
{
'Content-Type': 'application/json',
'Authorization':'Bearer '+token,
'cache-control': 'no-cache',
'X-Restli-Protocol-Version':'2.0.0', });
return this.http.post("https://api.linkedin.com/v2/shares" , body, {headers: this.headers});}
我得到这个问题:
我使用这篇文章修复了错误.. 它应该使用后端而不是前端的 REST API
解决方案
http://localhost 是一个不安全的请求来源,因此在许多情况下不受支持。尝试使用 Ngork https://ngrok.com/之类的隧道软件
推荐阅读
- c++ - C++20 中“关系”概念定义背后的动机
- java - 有没有办法写一个空文件但仍然不创建它?
- django - 匹配的查询不存在?
- python-3.x - python2中的函数注释
- sql - 如何使用双 LTRIM 加入
- python - Django(DRF)无法将数据发布到具有相似路径的 url
- javascript - 在 vue.js 中绑定时如何有效地显示文本而不是 null?
- c# - 如何从 WebApi 获取调用 API 的 Http Header
- jira - Jira 提供了哪些开箱即用的图表(没有任何插件)?
- apache - 知道如何在调用 Drupal 7 路由时加载 Drupal 8 路由吗?