Reputation: 727
I am trying to post to twitter using codebird.php. All the values are stored in a database, I didn't show the rest of the code here because I am sure it is working. However, I printed all the values for the community to see it.The problem is that when I used the library to tweet it does not post anything. Before I was testing getting the values from a form with method Post and it worked. I can't understand this error:
object(stdClass)#4 (3) { ["errors"]=> array(1) { [0]=> object(stdClass)#5 (2) { ["code"]=> int(189) ["message"]=> string(22) "Error creating status." } } ["httpstatus"]=> int(403) ["rate"]=> NULL }
Please anyone
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);
}
?>
Upvotes: 0
Views: 404
Reputation: 727
The problem was the order of my variables when I called the function:
$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);
}
Upvotes: 1