如何使用API​​或JavaScript张贴在Twitter的鸣叫(descrition和图像) [英] How to post tweet (descrition and images) in twitter using API or JAVASCRIPT

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

问题描述

我想用Twitter的API或JavaScript有啥code表示......请帮助或任何解决方案。

发布说明和图像

我必须使用以下code。

 包括('tmhOAuth.php');
包括('tmhUtilities.php');$ tmhOAuth =新tmhOAuth(阵列(
  CONSUMER_KEY'=> 2gfF75xRSwnJDgfuwXBUGj59kA',
  CONSUMER_SECRET'=> snGgVlYdVfgOeTVl8aQYG5BQRyEbgxqfgu9B9zTpRomIUh58',
  user_token'=> 148xf1479562-RYq76XIfgogfhjttdu0kLlWwQwEfgEM8wlRDMX44rUFPP',
  user_secret'=> I7saxfu751zzMnWChgffA0VAiRQIdf2JFwTMLragf6MK4aF8pjbg',
));  $图像='Chrysanthemum.jpg';
  $code = $ tmhOAuth->请求('POST','https://upload.twitter.com/1/statuses/update_with_media.json',
  阵列(
    媒体[]'=> @ {$}形象,
        状态=> 这是工作吗?
       )
       真的,//使用AUTH
       真正的多部分//
  );
  如果($$ç$ C == 200){
    tmhUtilities :: PR(json_de code($ tmhOAuth->响应['响应']));
  }其他{
    tmhUtilities :: PR($ tmhOAuth->响应['响应']);
  }

不过,我有这个错误:
JSON响应:

  {
错误:
    {
        消息:Twitter的REST API V1不再活动请迁移到API V1.1 https://dev.twitter.com/docs/api/1.1/overview。
        code:68
    }
 ]
}


解决方案

我猜你应该使用1.1​​ API
http://dev.twitter.com/blog/api-v1-is-retired

https://dev.twitter.com/docs/api/ 1.1 /后/状态/ update_with_media

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

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.

I have use the following code.

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']);
  }

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
    }
 ]
}

解决方案

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的鸣叫(descrition和图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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