如何使用Oauth-linkedin gem向用户收件箱发送消息?

时间:2013-11-05 14:41:55

标签: ruby-on-rails oauth linkedin omniauth sendmessage

我有一个使用Linkedin API帮助程序的应用程序,目前我能够使用get方法和端点地址(例如“/ v1 / people /〜/ connections”)获取“people”数据,这种情况是包含经过身份验证的用户朋友的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 =数字7位数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),但没有成功。我还阅读了关于发送消息的完整linkedin文档,尝试在JSON上发送它,搜索了诸如stackoverflow之类的论坛,但找不到任何实际使用帖子发送消息的人。

任何人都可以帮助我吗?标题中是否有需要设置的参数?我怎么能这样做?

谢谢和问候

PS:我的环境如下: Rails 3 红宝石1.9.3-P362 gem“omniauth-linkedin”

0 个答案:

没有答案