1

使用 php 将图像发布到 Twitter 不起作用。请检查我的代码。

<?
define( 'YOUR_CONSUMER_KEY' , '######################');
define( 'YOUR_CONSUMER_SECRET' , '######################');

require ('../../twitt/tmhOAuth.php');
require ('../../twitt/tmhUtilities.php');

$tmhOAuth = new tmhOAuth(array(
         'consumer_key'    => "######################",
         'consumer_secret' => "######################",
         'user_token'      => "######################",
         'user_secret'     => "######################",
));

$image = 'Tulips.jpg';

$code = $tmhOAuth->request( 'POST','https://upload.twitter.com/1/statuses/update_with_media.json',
   array(
        'media[]'  => "@{$image};",
        'status'   => 'message text written here',
   ),
    true, // use auth
    true  // multipart
);

if ($code == 200){
   tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
}else{
   tmhUtilities::pr($tmhOAuth->response['response']);
}
print_r($code);

?>

它不工作。我总是返回 0。这段代码有什么问题?任何人请帮助我....

4

0 回答 0