2012-09-12 171 views
26

最新的鳴叫我一直使用這個地址,讓我所有的鳴叫:掌握API 1.1

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=enriquemoreno

但由於API 1.1是地地道道的API 1已被棄用,我想我會嘗試改變。但是,新的地址是不工作:

http://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=enriquemoreno

我缺少什麼?

+0

你應該在這裏找到答案: http://stackoverflow.com/questions/12916539/simplest- php-example-retrieve-user-timeline-with-twitter-api-version-1-1 – lackovic10

+0

在這裏你可以找到一個使用twitter 1.1 REST api和curl獲取用戶推文的例子http://stackoverflow.com/questions/12916539 /簡單-PHP-示例-檢索 - 用戶的時間表與 - Twitter的API-版本-1-1 – lackovic10

+1

現在有一個C#解決方案現在可用:http://stackoverflow.com/questions/17067996/authenticate-and-request-a-users-timeline-with-twitter-api-1-1-oauth/17071447#17071447 – hutchonoid

回答

17

Someone寫了(聰明)片段放在香草的JavaScript獲取Twitter的小工具:

/********************************************************************* 
     #### Twitter Post Fetcher! #### 
     Coded by Jason Mayes 2013. 
     www.jasonmayes.com 
     Please keep this disclaimer with my code if you use it. Thanks. :-) 
     Got feedback or questions, ask here: http://goo.gl/JinwJ 
    *********************************************************************/ 
    var twitterFetcher=function(){var d=null;return{fetch:function(a,b){d=b;var c=document.createElement("script");c.type="text/javascript";c.src="http://cdn.syndication.twimg.com/widgets/timelines/"+a+"?&lang=en&callback=twitterFetcher.callback&suppress_response_codes=true&rnd="+Math.random();document.getElementsByTagName("head")[0].appendChild(c)},callback:function(a){var b=document.createElement("div");b.innerHTML=a.body;a=b.getElementsByClassName("e-entry-title");d(a)}}}(); 

    /* 
    * ### HOW TO USE: ### 
    * Create an ID: 
    * Go to www.twitter.com and sign in as normal, go to your settings page. 
    * Go to "Widgets" on the left hand side. 
    * Create a new widget for "user timeline". Feel free to check "exclude replies" 
    * if you dont want replies in results. 
    * Now go back to settings page, and then go back to widgets page, you should 
    * see the widget you just created. Click edit. 
    * Now look at the URL in your web browser, you will see a long number like this: 
    * 345735908357048478 
    * Use this as your ID below instead! 
    */ 

    twitterFetcher.fetch('345170787868762112', function(tweets){ 
     // Do what you want with your tweets here! For example: 
     var x = tweets.length; 
     var n = 0; 
     var element = document.getElementById('tweets'); 
     var html = '<ul>'; 
     while(n < x) { 
     if (tweets[n].innerText) { 
      html += '<li>' + tweets[n].innerText + '</li>'; 
     } else { 
      html += '<li>' + tweets[n].textContent + '</li>'; 
     } 
     n++; 
     } 
     html += '</ul>'; 
     element.innerHTML = html; 
    }); 

http://jsfiddle.net/jmayes/maT2Z/

不是最乾淨的方式,也許不是面向未來,但現在唯一的解決方案(我知道)訪問沒有OAuth的Twitter數據和服務器端支持。