使用龙卷风 LinkedinMixin 和 JSON 内容的 Linkedin Share Api

发布于 2024-12-15 04:12:40 字数 937 浏览 0 评论 0原文

我正在使用龙卷风网络服务器,并将 linkedin 集成到我的应用程序中,我使用的是 LinkedinMixin 类,该类是我从 github 中的非官方代码添加到框架中的。一切工作正常,但我希望能够使用共享 api

POST http://api.linkedin.com/v1/people/~/shares

linkedin API 采用 XML 格式,这就是为什么有时很难将其集成到龙卷风中的原因

https://developer.linkedin.com/documents/api-requests-json

我发现这篇文章告诉我发送

{ "contentType":"linkedin-html", "body":"我喜欢的更新" }

发布更新,但它向我发送 HTTP 401: 未经授权的获取 http: //api.linkedin.com/v1/people/~/shares?...

我想知道是否有人知道 linkedinMixin 的另一个版本: https://github.com/facebook/tornado/pull/236/files

如果有人能给我一个使用 JSON 的共享 API 的完整示例,

谢谢,

I'm using tornado web server and to integrate linkedin in my application I'm using the LinkedinMixin class that I add to the framework from an unofficial code in github. All is working perfectly, but I would like to be able to use the share api

POST
http://api.linkedin.com/v1/people/~/shares

The linkedin API is in XML, this is the reason why it's sometimes difficult to integrate it in tornado

https://developer.linkedin.com/documents/api-requests-json

I found this article which tell me to send

{
"contentType":"linkedin-html",
"body":"My Fancy Update"
}

to post an update but it sends me a HTTP 401: Unauthorized fetching http://api.linkedin.com/v1/people/~/shares?...

I would like to know if someone knows another version of linkedinMixin that this one :
https://github.com/facebook/tornado/pull/236/files

And if someone could give me a complete example of share API using JSON

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2024-12-22 04:12:40

我可能应该指出,我没有使用 LinkedIn API 或 Tornado 网络服务器的经验。不过,我已经使用 OAuth、JSON 和 XML 做了很多工作。

从您提到的类来看,它们

def linkedin_request(self, path, callback, access_token=None, post_args=None, **args):

完全符合您的要求。无需费心请求 JSON 等。它会为您完成。

我还没有真正分析过这些类,但我假设你的回调看起来像:

import json
def callback(data):
    # If data is a JSON string, parse it. (remove this if data is a dict)
    data = json.loads(data)

    # Do something with the data
    print data

def makeRequest():
    something.linkedin_request("/v1/people/~/shares", callback)

我希望这为你指明了正确的方向:-)

I should probably point out that I have no experience with the LinkedIn API or the Tornado webserver. I have done a lot of work with OAuth, JSON and XML though.

Judging by the class you mentioned, the

def linkedin_request(self, path, callback, access_token=None, post_args=None, **args):

does exactly what you want. No need to bother about requesting JSON, etc. It does it for you.

I haven't really analyzed the classes, but I'd assume that your callback would look something like :

import json
def callback(data):
    # If data is a JSON string, parse it. (remove this if data is a dict)
    data = json.loads(data)

    # Do something with the data
    print data

def makeRequest():
    something.linkedin_request("/v1/people/~/shares", callback)

I hope that this pointed you in the right direction :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文