twitterscriptを試す

twitter

twitterscriptを使うにもドキュメント情報がないですが
海外のBlogで書かれているものやsappari.orgさんにドキュメントを参考に試してみます。

 

まずは、Johannes Luderschmidtのサイトで基本的なソースが載ってるので
参考にソースを書く。

 

ユーザータイムラインの取得

import twitter.api.Twitter
import twitter.api.events.TwitterEvent
import twitter.api.data.*
 
var twt:Twitter
 
function test():void{
	twt = new Twitter();
	twt.loadUserTimeline("username");
	twt.addEventListener(TwitterEvent.ON_USER_TIMELINE_RESULT , userResult);
}
 
function userResult(e:TwitterEvent):void {		
	for (var i:int = 0; i <; e.data.length ; i++) {
		var state:TwitterStatus = e.data[i];
		trace(state.text +" from:" + state.user.screen_name  );
	}
}

 

twt.loadUserTimeline("username")

で簡単ににユーザータイムラインを取得できます。

ローカルで試す分にはセキュリティではじかれることもなく問題ないのですが
いざサーバアップするとtwitterのcrossdomain.xmlは制限がかかっているので
プロキシをかましてやる必要があります。

 

Woven Interactiveでそこら辺を解説しているのでblogの通り以下修正。

 

1.Twitter.asのtwitterへのリクエストパスの書かれているプロパティを変更

twitterにダイレクトにアクセスしているのを

private static const LOAD_FRIENDS_URL:String = "http://twitter.com/statuses/friends/$userId.xml";

proxyに渡す様に変更

private static const LOAD_FRIENDS_URL:String = "/proxy.php?path=statuses/friends/$userId.xml";

こんな感じですべて変更します。

 

2.proxy.phpをコピペして、プロキシとして作成

 

これでサーバでも動きます。
ベーシックなものがわかれば、後は応用ですね。

 

Filed under AS3, Twitter · Tagged with ,

Comments

One Response to “twitterscriptを試す”

Trackbacks

Check out what others are saying about this post...
  1. [...] 参考 http://blog.14lox.com/2010/04/22/twitterscript-proxy-problem/ twitterscriptを試す ②ツイッターのタイムラインのハイパーリンク表示だけを抽出。 [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.