使用Share API的LinkedIn上的内部服务错误? [英] Internal service error on LinkedIn using the Share API?

查看:47
本文介绍了使用Share API的LinkedIn上的内部服务错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用以下代码通过 Share API 发送帖子时.我得到了

While trying to send post via the Share API using the code as follows. I am getting

内部服务错误状态500

Internal service error status 500

PHP代码

$base_url = 'https://api.linkedin.com/v1/people/~/';
$url = $base_url . 'shares';
$xml  = '<share>';
$xml .= '<comment>' . 'test'. '</comment>';
$xml .= '<content>';
$xml .= '<title>' . 'TEST' . '</title>';
$xml .= '<submitted-url>' . 'http://www.google.com' . '</submitted-url>';
$xml .= '<description>' . 'description' . '</description>';
$xml .= '</content>';
$xml .= '<visibility><code>anyone</code></visibility>';
$xml .= '</share>';
$signature = new OAuthSignatureMethod_HMAC_SHA1();
$consumer_key = '';$consumer_secret = '';
$consumer = new OAuthConsumer('my_api_key', 'my_api_secret_key', NULL);
$token = new OAuthConsumer( $oauth['oauth_token'],  $oauth['oauth_token_secret'], 1);
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'POST', $url, array ());
$request->sign_request($signature, $consumer, $token);
$header = $request->to_header();
$response = _linkedin_http_request($url, $header, $xml);

函数具有的位置:

function _linkedin_http_request($url, $header, $body = NULL) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
    curl_setopt($ch, CURLOPT_URL, $url);
    if ($body) {
        curl_setopt($ch, CURLOPT_POST, 1);
        if ($body == 'token_request') {
            curl_setopt($ch, CURLOPT_POSTFIELDS, '');
        }
        else {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array($header, 'Content-Type: text/xml;charset=utf-8'));
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        }
    }

    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

我得到的错误如下.

$response = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
  <status>500</status>
  <timestamp>1411993375587</timestamp>
  <request-id>FYVRCIMJYO</request-id>
  <error-code>0</error-code>
  <message>Internal service error</message>
</error>

处理错误&无效令牌 指出这是来自LinkedIn的服务器问题.那我应该等一天然后再检查一次吗?

Handling Errors & Invalid Tokens states that it is a server issue from LinkedIn. So should I wait for a day and then check again?

推荐答案

在测试LinkedIn API时,我遇到了同样的问题.尝试将另一个网站用作< submitted-url></submitted-url>.

I had the same problem when testing the LinkedIn API. Try to use another website as <submitted-url></submitted-url>.

我还使用了" http://www.google.com ",并收到500内部服务错误.我将其更改为" http://www.yahoo.com ",它运行良好.我不知道为什么会这样.

I have also used 'http://www.google.com' and get 500 Internal service error. I changed that to 'http://www.yahoo.com', and it worked fine. I don't know exactly why that happens.

这篇关于使用Share API的LinkedIn上的内部服务错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆