我正在尝试使用codebird.php发布到Twitter。所有值都存储在数据库中,我没有在这里显示其余的代码,因为我确信它正在工作。但是,我打印了社区的所有值来查看它。问题是,当我使用库推文时,它不会发布任何内容。在我测试从方法Post获取表单中的值之前它已经有效了。我无法理解这个错误:
object(stdClass)#4(3){[" errors"] => array(1){[0] => object(stdClass)#5(2){[" code"] => int(189)[" message"] => string(22)"创建状态时出错。" }" httpstatus"] => int(403)[" rate"] => NULL}
请任何人
function twetting($value, $msg, $img, $link){
$values = queryTWTable($value);
$consumerKey = $values['ConsumerKey'];
$ConsumerSecret = $values['ConsumerSecret'];
$accessToken = $values['AccessToken'];
$accessTokenSecret = $values['AccessTokenSecret'];
echo "<br/><br/>";
echo "Consumer key is:".$consumerKey."<br/>";
echo "Consumer Secre Key".$ConsumerSecret."<br/>";
echo "Consumer acces token:".$accessToken."<br/>";
echo "Consumer acces token secret".$accessTokenSecret."<br/>";
echo "accouunt name:".$value."<br/>";
echo "message:".$msg."<br/>";
echo "image link:".$img."<br/>";
echo "link line:".$link."<br/>";
require_once('twitter/codebird-php/src/codebird.php');
\Codebird\Codebird::setConsumerKey($consumerKey,$ConsumerSecret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($accessToken, $accessTokenSecret);
$params = array(
'status' => $msg." ".$link,
'media[]' => $img
);
$reply = $cb->statuses_updateWithMedia($params);
var_dump($reply);
}
?>
答案 0 :(得分:1)
问题是我调用函数时变量的顺序:
$twitterArray = split(",",$row['TWitterAccounts']);
foreach ($twitterArray as $value) {
twetting($value,$row['Article'],$row['Img_url'],$row['Link']);
function twetting($value, $msg, $img, $link){
$values = queryTWTable($value);
$consumerKey = $values['ConsumerKey'];
$ConsumerSecret = $values['ConsumerSecret'];
$accessToken = $values['AccessToken'];
$accessTokenSecret = $values['AccessTokenSecret'];
echo "<br/><br/>";
echo "Consumer key is:".$consumerKey."<br/>";
echo "Consumer Secre Key".$ConsumerSecret."<br/>";
echo "Consumer acces token:".$accessToken."<br/>";
echo "Consumer acces token secret".$accessTokenSecret."<br/>";
echo "accouunt name:".$value."<br/>";
echo "message:".$msg."<br/>";
echo "image link:".$img."<br/>";
echo "link line:".$link."<br/>";
require_once('twitter/codebird-php/src/codebird.php');
\Codebird\Codebird::setConsumerKey($consumerKey,$ConsumerSecret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($accessToken, $accessTokenSecret);
$params = array(
'status' => $msg." ".$link,
'media[]' => $img
);
$reply = $cb->statuses_updateWithMedia($params);
}