我想通过使用Groups API添加评论来发布到LinkedIn群组帖子。我有一个脚本在localhost上运行fin,但在live(ubuntu / php5)服务器上失败了。好吧并没有真正失败,因为评论被发布,但脚本失败并引发错误(见下文)。这是我发布评论的代码:
$oauthc = new OAuth($oauth['linkedin']['consumerkey'],
$oauth['linkedin']['consumersecret'],
OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION); //initiate
$oauthc->enableDebug();
$oauthc->setNonce(rand());
$access_token = $_COOKIE['oauth_token'];
$access_token_secret =$_COOKIE['oauth_token_secret'];
$oauth_verifier = $_COOKIE['oauth_verifier'];
$oauthc->setToken($access_token,$access_token_secret);
error_log("setting access token", 0);
$commentData = $_POST['grpcomment'];
$pid = $_POST['grpPostId'];
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<comment>
<text>'.$commentData.'</text>
</comment>';
$headers = array('Content-Type' => 'text/xml');
//$oauthc->disableRedirects();
$data = $oauthc->fetch('http://api.linkedin.com/v1/posts/'.$pid.'/comments',$xml,OAUTH_HTTP_METHOD_POST,$headers);
但是我收到以下错误:
Warning: OAuth::fetch(http://api.linkedin.com/v1/posts/g-4185217-S-81514256/comments)
[oauth.fetch]: failed to open stream: Redirection limit reached, aborting in
/var/www/deloitte-staging/public/wp-content/themes/DBA/single-linkedin_discussions.php
on line 106
line 106
是上面代码片段的结尾,评论被发布,但脚本失败了(我有其他重要的事情在这部分之后运行,否则我不会是一个拥抱问题)。谢谢你的帮助。