IE6-8 is Not Supported

PHP を使った Twitter API 1.1 の基本操作

PHP での Twitter クライアントを作った際に使った REST API の基本操作をメモしておきます。
あまり詳しく書かないので、一度触ったことある人 & 動けばいい人向け。

今回紹介していない API は REST API のページを参照してみてください。

Twitter REST API 1.1


1. Home Timeline

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/statuses/home_timeline.json", "GET", array("include_entities"=>"true", "page"=>$page));

2. Mentions Timeline

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/statuses/mentions_timeline.json", "GET", array("include_entities"=>"true", "page"=>$page));

3. Tweet & Delete

	// ツイート
	$req = $to->OAuthRequest("http://api.twitter.com/1.1/statuses/update.json", "POST", array("status"=>$tweet, "in_reply_to_status_id"=>$statusID));
	// ツイート削除
	$req = $to->OAuthRequest("http://api.twitter.com/1.1/statuses/destroy/".$status_id.".json", "POST" , array());

4. Retweet

	$req = $to->OAuthRequest("http://api.twitter.com/1.1/statuses/retweet/".$status_id.".json", "POST", array());

5. Favorite & UnFavorite

	// お気に入り
	$req = $to->OAuthRequest("http://api.twitter.com/1.1/favorites/create.json?id=".$status_id."", "POST", array());
	// お気に入り削除
	$req = $to->OAuthRequest("http://api.twitter.com/1.1/favorites/destroy.json?id=".$status_id."", "POST", array());

6. User Timeline

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/statuses/user_timeline.json?include_entities=true","GET",array("screen_name"=>$screenname, "page"=>$page));

7. User Profile

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/users/show.json", "GET", array("include_entities"=>"true", "screen_name"=>$screenname));

8. User Friends

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/friends/list.json", "GET", array("cursor"=>$cursor, "screen_name"=>$screenname));

9. User Followers

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/followers/list.json", "GET", array("cursor"=>$cursor, "screen_name"=>$screenname));

10. User Favorite

	$req = $to->OAuthRequest("https://api.twitter.com/1.1/favorites/list.json?include_entities=true","GET",array("screen_name"=>$screenname, "page"=>$page));

11. Follow & UnFollow

	// フォロー
	$req = $to->OAuthRequest("https://api.twitter.com/1.1/friendships/create.json", "POST", array("user_id"=>$user_id, "follow"=>"false"));
	// アンフォロー
	$req = $to->OAuthRequest("https://api.twitter.com/1.1/friendships/destroy.json", "POST", array("user_id"=>$user_id));

以上になります。

ads by google