我有一个使用 Linkedin API 帮助程序的应用程序,目前我能够使用 get 方法和端点地址(例如“/v1/people/~/connections”)获取“人”数据,在这种情况下返回包含经过身份验证的用户朋友的 XML。
[13] myapp » u = User.find(3)
[14] myapp » u.linkedin.get("/v1/people/~/connections").body
=> "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<connections total=\"457\" count=\"455\" start=\"0\">\n (...)
但是,我无法发送消息;尽管有标志 w_messages,它仍然返回 401 错误,未授权,即使我尝试向自己发送消息(其中 MYUSERID=numeric 7 digit id):
[15] myapp » u.linkedin.post('http://api.linkedin.com/v1/people/~/mailbox', '<mailbox-item> <recipients> <recipient> <person path="/people/~"/> </recipient> <recipient> <person path="/people/MYUSERID" /> </recipient> </recipients> <subject>Congratulations on your new position.</subject> <body>You are certainly the best person for the job!</body> </mailbox-item>').body
=> "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<error>\n <status>401</status>\n <timestamp>1383661453052</timestamp>\n <request-id>T36BEYPC1T</request-id>\n <error-code>0</error-code>\n <message>[unauthorized]. OAU:4weqo9zxt1zt|abcdefg-efgh-ijkl-mnop-14875f6dad97|*01|*01:1383661458:8du6NgLjwZTRDzTexg/fJcZCiBY=</message>\n</error>\n"
我尝试了变体和组合,尝试使用 UID(符号 ID),但没有成功。我还阅读了关于发送消息的完整链接文档,尝试在 JSON 上发送,搜索了诸如 stackoverflow 之类的论坛,但找不到任何实际使用这些帖子发送消息的人。
谁能帮我?标头中是否有需要设置的参数?我怎样才能做到这一点?
谢谢并恭祝安康
PS:我的环境如下:Rails 3 ruby-1.9.3-p362 gem "omniauth-linkedin"