来自LinkedIn终端的Linkedin HTTP响应不是代码201

时间:2015-04-07 13:43:28

标签: php api oauth linkedin

我正在尝试进行API调用:https://api.linkedin.com/v1/companies/2414183/shares

LinkedIn返回一个错误的数组,我无法理解问题所在。

前几天一切都很完美。

array(5) {
 'linkedin' =>
  string(5487) "<!-- EF of static content included-->
<html>
<head>
  <title>Error</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <style type="text/css">
/* GLOBAL */
body { margin: 0; padding: 0 0 10px 0; background: #FFF; color: #000; font: 82% arial, helvetica, "Nimbus Sans L", sans-serif; text-align: center; min-width: 775px; }
table { font-size: 100%; border: 0; }
th { text-align: left; }
tr.tblhdr { background: #999; }
.helper { font-size: 85%; }
.spacer { clear: both; line-height: 0; height: 0; _font-size: 1px; }
.indent { margin-left: 35px; }
.top { margin-top: 0 !important; }
.bottom { margin-bottom: 0 !important; }
.btn { text-align: center; }
.right { text-align: right; }
.preview { background: #9CF; }
.even, .odd { background: #EEE; }
abbr { text-decoration: none; border: none; font-style: normal; }
sup { font-size: 70%; }
div.skip { position: absolute; left: -999px; width: 990px; }
.dim { color: #999 !important; }
.vmid { vertical-align: middle; }
.vtop { vertical-align: top; }
."...
  'info' =>
  array(26) {
'url' =>
string(52) "https://api.linkedin.com/v1/companies/2414183/shares"
'content_type' =>
string(9) "text/html"
'http_code' =>
int(405)
'header_size' =>
int(439)
'request_size' =>
int(497)
'filetime' =>
int(-1)
'ssl_verify_result' =>
int(0)
'redirect_count' =>
int(0)
'total_time' =>
double(2.5)
'namelookup_time' =>
double(0)
'connect_time' =>
double(0.062)
'pretransfer_time' =>
double(1.265)
'size_upload' =>
double(1328)
'size_download' =>
double(5487)
'speed_download' =>
double(2194)
'speed_upload' =>
double(531)
'download_content_length' =>
double(5487)
'upload_content_length' =>
double(1328)
'starttransfer_time' =>
double(2.265)
'redirect_time' =>
double(0)
'certinfo' =>
array(0) {
}
'primary_ip' =>
string(14) "255.255.255.255"
'primary_port' =>
int(443)
'local_ip' =>
string(13) "255.255.255.255"
'local_port' =>
int(30965)
'redirect_url' =>
string(0) ""
  }
  'oauth' =>
  array(2) {
    'header' =>
    string(329) "Authorization: OAuthrealm="http%3A%2F%2Fapi.linkedin.com",oauth_version="1.0",oauth_nonce="d2475a156755d8f6aece5a783ec4f8bd",oauth_timestamp="1428413208",oauth_consumer_key="xxxxx",oauth_token="xxxxx",oauth_signature_method="HMAC-SHA1",oauth_signature="xxxxxxx"
'string' =>
string(299) "POST&https%3A%2F%2Fapi.linkedin.com%2Fv1%2Fcompanies%2F2414183%2Fshares&oauth_consumer_key%xxxxx%26oauth_nonce%3Dd2475a156755d8f6aece5a783ec4f8bd%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1428413208%26oauth_token%xxxxx%26oauth_version%3D1.0"
  }
  'success' =>
  bool(false)
  'error' =>
  string(54) "HTTP response from LinkedIn end-point was not code 201"
}

经过更详细的调查后发现,帖子没有发送,其中的字段是&#34; title&#34;或&#34;评论&#34;包含特殊字符,例如 $ / 。 第一个示例成功发布,但第二个返回错误;

1

<?xml version="1.0" encoding="UTF-8"?>
<share>
<content>
    <title>1 oz Britannia Silver Coin 999</title>
    <submitted-url>http://example.com</submitted-url>
    <submitted-image-url>http://example.com/image.jpg</submitted-image-url>
    <description>Some text</description>
</content>
<comment>Overview of 1 oz Britannia Silver Coin 999</comment>
    <visibility>
        <code>anyone</code>
    </visibility>
</share>

2

<?xml version="1.0" encoding="UTF-8"?>
<share>
    <content>
        <title>1 oz Canadian Vancouver Olympics Thunderbird Totem $50 Gold Coin 9999</title>
        <submitted-url>http://example.com</submitted-url>
        <submitted-image-url>http://example.com/image.jpg</submitted-image-url>
        <description>Some text</description>
    </content>
    <comment>Overview of 1 oz Canadian Vancouver Olympics Thunderbird Totem $50 Gold Coin 9999</comment>
    <visibility>
        <code>anyone</code>
    </visibility>
    </share>

1 个答案:

答案 0 :(得分:0)

尝试添加您的令牌:https://api.linkedin.com/v1/companies/2414183/shares?oauth2_access_token=your_token 如果你使用php,你可以试试这个:https://github.com/ashwinks/PHP-LinkedIn-SDK来获得认证后的你的令牌