如何使用API​​或JAVASCRIPT在Twitter上发布推文(描述和图像) [英] How to post tweet (description and images) in twitter using API or JAVASCRIPT

查看:75
本文介绍了如何使用API​​或JAVASCRIPT在Twitter上发布推文(描述和图像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Twitter API或JavaScript发布描述和图片,所以代码是什么...请帮助或任何解决方案。

I want to post description and images using twitter API or JavaScript so what the code for that... Please help or any solution for that.

我使用以下代码。

include('tmhOAuth.php');
include('tmhUtilities.php');

$tmhOAuth = new tmhOAuth(array(
  'consumer_key'    => '2gfF75xRSwnJDgfuwXBUGj59kA',
  'consumer_secret' => 'snGgVlYdVfgOeTVl8aQYG5BQRyEbgxqfgu9B9zTpRomIUh58',
  'user_token'      => '148xf1479562-RYq76XIfgogfhjttdu0kLlWwQwEfgEM8wlRDMX44rUFPP',
  'user_secret'     => 'I7saxfu751zzMnWChgffA0VAiRQIdf2JFwTMLragf6MK4aF8pjbg',
));

  $image = 'Chrysanthemum.jpg';
  $code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1/statuses/update_with_media.json',
  array(
    'media[]'  => "@{$image}",
        "status"   => "Is this working now?"
       ),
       true, // use auth
       true  // multipart
  );
  if ($code == 200) {
    tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
  } else {
    tmhUtilities::pr($tmhOAuth->response['response']);
  }

但是,我有这个错误:
JSON响应:

But , i have got this error: JSON RESPONSE:

{
errors: [
    {
        message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.",
        code: 68
    }
 ]
}


推荐答案

我想你应该使用1.1 API
http://dev.twitter.com/blog/api-v1已退休

I guess you should use the 1.1 API http://dev.twitter.com/blog/api-v1-is-retired

https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media

Resource URL
https://api.twitter.com/1.1/statuses/update_with_media.json

这篇关于如何使用API​​或JAVASCRIPT在Twitter上发布推文(描述和图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆