Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php将图像发布到twitter不起作用_Php_Twitter - Fatal编程技术网

使用php将图像发布到twitter不起作用

使用php将图像发布到twitter不起作用,php,twitter,Php,Twitter,使用php将图像发布到twitter不起作用。请检查我的密码 <? define( 'YOUR_CONSUMER_KEY' , '######################'); define( 'YOUR_CONSUMER_SECRET' , '######################'); require ('../../twitt/tmhOAuth.php'); require ('../../twitt/tmhUtilities.php'); $tmhOAuth = ne

使用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。此代码中的问题是什么?任何人请帮帮我……

我想你是在尝试,但我看到的唯一区别是你使用$image='Tulips.jpg';它们在解析为当前目录的映像路径中包括。试试$image='./Tulips.jpg';调试您的代码,检查每个值,检查PHP错误日志。@HugoDelsing我用那个路径试过了。它不起作用。@Jocelyn值是正确的,问题在于twitter发布。