【问题标题】:getting 200 ok code but image not uploaded on twitter using codebird获得 200 个 ok 代码,但图片未使用 codebird 上传到 Twitter
【发布时间】: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


【解决方案1】:

我通过修改修复了它

$reply = $cb->media_upload(array(
    'media' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
));

$params = array(
  'status' => 'Auto Post on Twitter with PHP http://goo.gl/OZHaQD #php #twitter',
  'media[]' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
);

// send tweet with these medias
/*$reply = $cb->media_upload(array(
    'media[]' => "@http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg"
));*/
$reply = $cb->statuses_updateWithMedia($params);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-18
    • 2020-02-09
    • 2022-01-06
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    相关资源
    最近更新 更多