使用PHP在Twitter上上传图像
发布时间:2020-12-13 17:51:01 所属栏目:PHP教程 来源:网络整理
导读:如何在不使用 PHP登录的情况下使用consumer_key和consumer_secret在Twitter Wall上传图像? 请帮助我非常感谢. 好吧,我得到了答案,下载 Twitter Api for php创造了一个功能. function image_upload(){ define( 'YOUR_CONSUMER_KEY','your twitter app consum
如何在不使用
PHP登录的情况下使用consumer_key和consumer_secret在Twitter Wall上传图像?
请帮助我&非常感谢.
好吧,我得到了答案,下载
Twitter Api for php&创造了一个功能.
function image_upload(){ define( 'YOUR_CONSUMER_KEY','your twitter app consumer key'); define( 'YOUR_CONSUMER_SECRET','your twitter app consumer key secret'); require ('twitt/tmhOAuth.php'); require ('twitt/tmhUtilities.php'); $tmhOAuth = new tmhOAuth(array( 'consumer_key' => "YOUR_CONSUMER_KEY",'consumer_secret' => "YOUR_CONSUMER_SECRET",'user_token' => "YOUR_OAUTH_TOKEN",'user_secret' => "YOUR_OAUTH_TOKEN_SECRET",)); $image = 'image.jpg'; $code = $tmhOAuth->request( 'POST','https://upload.twitter.com/1/statuses/update_with_media.json',array( 'media[]' => "@{$image};type=image/jpeg;filename={$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']); } return tmhUtilities; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |