【发布时间】:2014-12-03 22:02:15
【问题描述】:
我正在使用 codebird-php 在 twitter 上发布图像,当我这样做时,我得到 200 ok http 代码,但图像未上传。这是我的代码:
<?php
session_start();
require_once ('./src/codebird.php');
\Codebird\Codebird::setConsumerKey('74AFitlDilqB2HlFQ8Cjszz6I', 'tDlVndY7iJG8loFGG1sq3gJaj59CwNx6UV5o6wEtV0LJebNJ0y'); // static, see 'Using multiple Codebird instances'
$cb = \Codebird\Codebird::getInstance();
$access_token = $_SESSION['access_token'];
$cb->setToken($access_token['oauth_token'], $access_token['oauth_token_secret']);
//$reply = $cb->statuses_update('status=Whohoo, I just again tweeted!');
// send tweet with these medias
$reply = $cb->media_upload(array(
'media' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
));
print_r($reply);
?>
这就是我在浏览器中运行它的结果:
stdClass Object ( [media_id] => 540134777223790592 [media_id_string] => 540134777223790592 [size] => 179801 [image] => stdClass Object ( [w] => 1366 [h] => 768 [image_type] => image/jpeg ) [httpstatus] => 200 [rate] => )
PS:我在 localhost 上运行它,推文有效但不是图像,我正在使用 Abrahams oAuth 获取 oAuth 令牌。
【问题讨论】:
-
@alda1234 我不明白我应该打开和关闭什么?如果您的意思是注销并重新登录并再次进行身份验证,那么我这样做并没有帮助。
标签: php twitter twitter-oauth