1

我正在使用 LinkedIn 邀请 API,但我无法使用搜索结果中的人员 ID 向用户发送邀请

搜索到的人结果

**
"{\"people\":{\"total\":2,\"all\":[{\"api_standard_profile_request\":{\"headers\":{\"total\":1,\"all\":[{\"name\":\"x-li-auth-token\",\"value\":\"NAME_SEARCH:tdLy\"}]},\"url\":\"http://api.linkedin.com/v1/people/tp2Z82Xa_I\"},\"first_name\":\"Dev\",\"id\":\"tp2Z8sad2Xa_I\",\"last_name\":\"ruby\"},{\"api_standard_profile_request\":{\"headers\":{\"total\":1,\"all\":[{\"name\":\"x-li-auth-token\",\"value\":\"NAME_SEARCH:ZbY6\"}]},\"url\":\"http://api.linkedin.com/v1/people/TyaEtFbxzL\"},\"first_name\":\"dev\",\"id\":\"TyaEtFbsdsaxzL\",\"last_name\":\"ruby\"}]}}"** 

以及随后的邀请方法

def send_invitation(options)
  path = "/people/~/mailbox"
  message = {
      "recipients" => {
          "values" => [
              {
                  "person" => {
                      "_path" => "/people/id=#{options[:email]}",
                      "first-name" => options[:first_name],
                      "last-name" => options[:last_name]
                  }
              }]
      },
      "subject" => "Invitation to connect.",
      "body" => options[:body],
      "item-content" => {
          "invitation-request" => {
              "connect-type" => "friend",
              "authorization" => {"name" => "x-li-auth-token","value" => "NAME_SEARCH:tdLy"}
          }
      }
  }
  post(path, MultiJson.dump(message), "Content-Type" => "application/json")
end

所以当我打电话时我收到了这个错误client.send_invitation(options)

LinkedIn::Errors::GeneralError: (400): Invalid authorization name/value {x-li-auth-token}/{NAME_SEARCH:tdLy}
4

1 回答 1

2

工作正常

名称应该是NAME_SEARCH并且应该是tdLy不是我上面问的。我必须将值从 oauth 标头中拆分出来。

"授权" => {:"名称" => 'NAME_SEARCH',:"值" => 'tdLy'}

于 2014-06-25T16:12:38.163 回答