Twitter関連Twitter REST API:アカウント関連
- account/verify_credentials〔認証ユーザーが有効なユーザーかどうか調べる(要認証)〕
- account/rate_limit_status〔認証ユーザーがAPIの限界に達する前にリクエストの残数を取得(要認証)〕
- account/end_session〔認証ユーザーのセッションを終了(要認証)※非推奨〕
- account/update_delivery_device〔認証ユーザーがデバイスTwitterが認証ユーザーにアップデートを提供(要認証)※非推奨〕
- account/update_profile_colors〔認証ユーザーのプロフィールページの色を更新(要認証)〕
- account/update_profile_image〔認証ユーザーのプロフィール画像を設定(要認証)〕
- account/update_profile_background_image〔認証ユーザーのプロフィールの背景画像を更新(要認証)〕
- account/update_profile〔認証ユーザーのプロフィールの情報を更新(要認証)〕
account/verify_credentials
認証ユーザーが有効なユーザーかどうか調べる(要認証)
2009/7/18
http://api.twitter.com/1/account/verify_credentials.[xml|json]
このメソッドは、認証ユーザーが有効なユーザーかどうか調べるのに有用です。 認証に成功した場合は、HTTP 200 OKレスポンスコードとリクエストするユーザー情報を返します。 認証に失敗した場合は401のステータスコードとエラーメッセージを返します。
パラメーター
パラメーター | 説明 | |
---|---|---|
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/verify_credentials.xml?include_entities=true |
取得サンプル(XML/JSON)
<?xml version="1.0" encoding="UTF-8"?> <user> <id>7948862</id> <name>つんつ</name> <screen_name>cocoism</screen_name> <location>カワタマ or オモサン</location> <description>青山でWeb系のお仕事してます。デザイナーズレストランははるか昔に卒業済。芋焼酎と焼鳥が大好きで居心地のいい呑み屋でおやじ談義するのがライフワーク。最近は日本酒をお勉強中。家では大人しく猛犬チワワのママしてます。iPhone4/Xperia所有。</description> <profile_image_url>http://a0.twimg.com/profile_images/1202496271/usa_normal.png</profile_image_url> <url>http://phpjavascriptroom.com/</url> <protected>false</protected> <followers_count>613</followers_count> <profile_background_color>8350a1</profile_background_color> <profile_text_color>f2afcf</profile_text_color> <profile_link_color>f2afcf</profile_link_color> <profile_sidebar_fill_color>8350a1</profile_sidebar_fill_color> <profile_sidebar_border_color>8350a1</profile_sidebar_border_color> <friends_count>526</friends_count> <created_at>Sat Aug 04 05:52:33 +0000 2007</created_at> <favourites_count>441</favourites_count> <utc_offset>32400</utc_offset> <time_zone>Tokyo</time_zone> <profile_background_image_url>http://a1.twimg.com/profile_background_images/187449144/02.png</profile_background_image_url> <profile_background_tile>true</profile_background_tile> <profile_use_background_image>true</profile_use_background_image> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>false</following> <statuses_count>4989</statuses_count> <lang>ja</lang> <contributors_enabled>false</contributors_enabled> <follow_request_sent>false</follow_request_sent> <listed_count>51</listed_count> <show_all_inline_media>true</show_all_inline_media> <default_profile>false</default_profile> <default_profile_image>false</default_profile_image> <is_translator>false</is_translator> <status> <created_at>Wed May 25 07:35:45 +0000 2011</created_at> <id>73291145098166272</id> <text>ちわわんニュース紙 is out! http://bit.ly/gUy9AQ ▸ Top stories today via @mynews_bot01 @madame_sachi @whitypapa @chihuahua_news</text> <source><a href="http://paper.li" rel="nofollow">Paper.li</a></source> <truncated>false</truncated> <favorited>false</favorited> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <in_reply_to_screen_name></in_reply_to_screen_name> <retweet_count>0</retweet_count> <retweeted>false</retweeted> <geo/> <coordinates/> <place/> <contributors/> <entities> <user_mentions> <user_mention end="76" start="63"> <id>155174229</id> <screen_name>mynews_bot01</screen_name> <name>ニュース(社会)</name> </user_mention> <user_mention end="90" start="77"> <id>140647827</id> <screen_name>madame_sachi</screen_name> <name>マダムサチ</name> </user_mention> <user_mention end="101" start="91"> <id>147257919</id> <screen_name>whitypapa</screen_name> <name>whitypapa</name> </user_mention> <user_mention end="117" start="102"> <id>286778459</id> <screen_name>chihuahua_news</screen_name> <name> チワワ村</name> </user_mention> </user_mentions> <urls> <url end="38" start="18"> <url>http://bit.ly/gUy9AQ</url> <expanded_url/> </url> </urls> <hashtags/> </entities> </status> </user>
json[show_all_inline_media]=1 json[geo_enabled]=1 json[profile_background_color]=8350a1 json[protected]= json[listed_count]=51 json[profile_background_image_url]=http://a1.twimg.com/profile_background_images/187449144/02.png json[followers_count]=613 json[location]=カワタマ or オモサン json[name]=つんつ json[default_profile]= json[notifications]= json[profile_image_url]=http://a0.twimg.com/profile_images/1202496271/usa_normal.png json[id_str]=7948862 json[statuses_count]=4989 json[utc_offset]=32400 json[profile_text_color]=f2afcf json[url]=http://phpjavascriptroom.com/ json[profile_sidebar_fill_color]=8350a1 json[description]=青山でWeb系のお仕事してます。デザイナーズレストランははるか昔に卒業済。芋焼酎と焼鳥が大好きで居心地のいい呑み屋でおやじ談義するのがライフワーク。最近は日本酒をお勉強中。家では大人しく猛犬チワワのママしてます。iPhone4/Xperia所有。 json[screen_name]=cocoism json[default_profile_image]= json[lang]=ja json[profile_background_tile]=1 json[created_at]=Sat Aug 04 05:52:33 +0000 2007 json[status]['in_reply_to_screen_name']= json[status]['in_reply_to_user_id_str']= json[status]['contributors']= json[status]['retweeted']= json[status]['truncated']= json[status]['id_str']=73291145098166272 json[status]['text']=ちわわんニュース紙 is out! http://bit.ly/gUy9AQ ▸ Top stories today via @mynews_bot01 @madame_sachi @whitypapa @chihuahua_news json[status]['entities']['user_mentions']['0']=Array json[status]['entities']['user_mentions']['1']=Array json[status]['entities']['user_mentions']['2']=Array json[status]['entities']['user_mentions']['3']=Array json[status]['entities']['urls']['0']=Array json[status]['in_reply_to_status_id']= json[status]['created_at']=Wed May 25 07:35:45 +0000 2011 json[status]['place']= json[status]['in_reply_to_user_id']= json[status]['id']=7.32911450982E+16 json[status]['source']=Paper.li json[status]['favorited']= json[status]['in_reply_to_status_id_str']= json[status]['coordinates']= json[status]['geo']= json[status]['retweet_count']=0 json[verified]= json[is_translator]= json[favourites_count]=441 json[profile_link_color]=f2afcf json[id]=7948862 json[follow_request_sent]= json[friends_count]=526 json[profile_sidebar_border_color]=8350a1 json[time_zone]=Tokyo json[contributors_enabled]= json[following]= json[profile_use_background_image]=1
account/rate_limit_status
認証ユーザーがAPIの限界に達する前にリクエストの残数を取得(要認証)
2009/7/18
http://api.twitter.com/1/account/rate_limit_status.[xml|json]
1時間当たりの上限リクエスト数など、TwitterのAPI制限に達するまでに利用できるAPIリクエスト数を返します。 このメソッドは、認証の有無によって返される値が異なります。 認証ありでAPIをたたくと、認証ユーザー自身のAPI制限状況が返ります。 認証なしだと、IPアドレスでのAPI制限状況が返ります。、
取得サンプル(認証なし)(XML/JSON)
json[hourly_limit]=150 json[reset_time]=Thu May 26 18:04:23 +0000 2011 json[reset_time_in_seconds]=1247403366 json[remaining_hits]=136
json[remaining_hits]=141 json[reset_time]=Wed May 25 09:48:19 +0000 2011 json[hourly_limit]=150 json[reset_time_in_seconds]=1306316899
取得サンプル(認証あり)(XML/JSON)
<?xml version="1.0" encoding="UTF-8"?> <hash> <reset-time-in-seconds type="integer">1306315818</reset-time-in-seconds> <reset-time type="datetime">2011-05-25T09:30:18+00:00</reset-time> <remaining-hits type="integer">332</remaining-hits> <hourly-limit type="integer">350</hourly-limit> </hash>
json[remaining_hits]=332 json[reset_time]=Wed May 25 09:30:18 +0000 2011 json[hourly_limit]=350 json[reset_time_in_seconds]=1306315818
設置サンプル
IPアドレスでのAPI制限状況を取得して表示します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ja" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <title>Twitter REST API:アカウント関連:account/rate_limit_status(IPアドレスでのAPI制限状況) | 設置サンプル</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript" src="/content/lib/jquery/jquery.jsonp.js"></script> <!-- JS --> <script type="text/javascript"> $(function(){ var url="http://api.twitter.com/1/account/rate_limit_status.json?callback={callback}"; $.getJSONP(url, function(json){ var s=""; s+="<li>残リクエスト数: "+json.remaining_hits+"回</li>"; s+="<li>1時間当たりのリクエスト回数制限: "+json.hourly_limit+"回</li>"; s+="<li>リセット日時の秒数: "+json.reset_time_in_seconds+"</li>"; s+="<li>リセット日時: "+json.reset_time+"</li>"; $("#res").html("<ul>"+s+"</ul>"); }); }); </script> <style type="text/css"> </style> </head> <body> <div id="wrap"> <h1>Twitter REST API:アカウント関連:account/rate_limit_status(IPアドレスでのAPI制限状況) | 設置サンプル</h1> <p>このAPIは認証なしの場合は、IPアドレスでのAPI制限状況が返ります。</p> <!-- CODE --> <div id="res"></div> <!-- / CODE --> </div> </body> </html>
account/end_session
認証ユーザーのセッションを終了(要認証)※非推奨
2009/7/18
※非推奨
http://api.twitter.com/1/account/end_session.[xml|json]
認証ユーザーのセッションを終了し、NULLクッキーを返します。 このメソッドは、ウィジェットのようなクライアント側のアプリケーションからユーザーに署名するのに有用です。
account/update_delivery_device
認証ユーザーがデバイスTwitterが認証ユーザーにアップデートを提供(要認証)※非推奨
2009/7/18
※非推奨
http://api.twitter.com/1/account/update_delivery_device.[xml|json]
デバイスTwitterが認証ユーザーにアップデートを提供します。 deviceパラメータを指定しない場合は、IMまたはSMSのアップデートを無効にします。
パラメーター
パラメーター | 説明 | |
---|---|---|
device | 必須 |
sms、im、noneのいずれかを指定。 例)http://api.twitter.com/1/account/update_delivery_device.xml?device=sms |
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/update_delivery_device.json?include_entities=true |
account/update_profile_colors
認証ユーザーのプロフィールページの色を更新(要認証)
2009/7/18
http://api.twitter.com/1/account/update_profile_colors.[xml|json]
Twitter公式サイト上の認証ユーザーのプロフィールページの配色をRGB形式(#rgb)またはRRGGBB形式(#rrggbb)で設定します。
パラメーター
パラメーター | 説明 | |
---|---|---|
profile_background_color | 任意 | プロフィールページの背景色 |
profile_text_color | 任意 | プロフィールページの文字色 |
profile_link_color | 任意 | プロフィールページのリンク色 |
profile_sidebar_fill_color | 任意 | プロフィールページのサイドバーの色 |
profile_sidebar_border_color | 任意 | プロフィールページのサイドバーの枠線色 |
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/update_profile_colors.json?profile_text_color=ff6699&include_entities=true |
取得サンプル(認証なし)(XML/JSON)
<?xml version="1.0" encoding="UTF-8"?> <user> <id>7948862</id> <name>つんつ</name> <screen_name>cocoism</screen_name> <location>カワタマ or オモサン</location> <description>青山でWeb系のお仕事してます。デザイナーズレストランははるか昔に卒業済。芋焼酎と焼鳥が大好きで居心地のいい呑み屋でおやじ談義するのがライフワーク。最近は日本酒をお勉強中。家では大人しく猛犬チワワのママしてます。iPhone4/Xperia所有。</description> <profile_image_url>http://a0.twimg.com/profile_images/1202496271/usa_normal.png</profile_image_url> <url>http://phpjavascriptroom.com/</url> <protected>false</protected> <followers_count>613</followers_count> <profile_background_color>8350a1</profile_background_color> <profile_text_color>ff6699</profile_text_color> <profile_link_color>f2afcf</profile_link_color> <profile_sidebar_fill_color>8350a1</profile_sidebar_fill_color> <profile_sidebar_border_color>8350a1</profile_sidebar_border_color> <friends_count>526</friends_count> <created_at>Sat Aug 04 05:52:33 +0000 2007</created_at> <favourites_count>441</favourites_count> <utc_offset>32400</utc_offset> <time_zone>Tokyo</time_zone> <profile_background_image_url>http://a1.twimg.com/profile_background_images/187449144/02.png</profile_background_image_url> <profile_background_tile>true</profile_background_tile> <profile_use_background_image>true</profile_use_background_image> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>false</following> <statuses_count>4989</statuses_count> <lang>ja</lang> <contributors_enabled>false</contributors_enabled> <follow_request_sent>false</follow_request_sent> <listed_count>51</listed_count> <show_all_inline_media>true</show_all_inline_media> <default_profile>false</default_profile> <default_profile_image>false</default_profile_image> <is_translator>false</is_translator> <status> <created_at>Wed May 25 07:35:45 +0000 2011</created_at> <id>73291145098166272</id> <text>ちわわんニュース紙 is out! http://bit.ly/gUy9AQ ▸ Top stories today via @mynews_bot01 @madame_sachi @whitypapa @chihuahua_news</text> <source><a href="http://paper.li" rel="nofollow">Paper.li</a></source> <truncated>false</truncated> <favorited>false</favorited> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <in_reply_to_screen_name></in_reply_to_screen_name> <retweet_count>0</retweet_count> <retweeted>false</retweeted> <geo/> <coordinates/> <place/> <contributors/> </status> </user>
json[profile_background_color]=8350a1 json[protected]= json[statuses_count]=4989 json[profile_background_image_url]=http://a1.twimg.com/profile_background_images/187449144/02.png json[followers_count]=613 json[location]=カワタマ or オモサン json[name]=つんつ json[notifications]= json[profile_image_url]=http://a0.twimg.com/profile_images/1202496271/usa_normal.png json[id_str]=7948862 json[default_profile_image]= json[default_profile]= json[utc_offset]=32400 json[profile_text_color]=ff6699 json[url]=http://phpjavascriptroom.com/ json[profile_sidebar_fill_color]=8350a1 json[description]=青山でWeb系のお仕事してます。デザイナーズレストランははるか昔に卒業済。芋焼酎と焼鳥が大好きで居心地のいい呑み屋でおやじ談義するのがライフワーク。最近は日本酒をお勉強中。家では大人しく猛犬チワワのママしてます。iPhone4/Xperia所有。 json[screen_name]=cocoism json[is_translator]= json[lang]=ja json[profile_background_tile]=1 json[created_at]=Sat Aug 04 05:52:33 +0000 2007 json[status]['in_reply_to_screen_name']= json[status]['in_reply_to_user_id_str']= json[status]['contributors']= json[status]['retweeted']= json[status]['truncated']= json[status]['id_str']=73291145098166272 json[status]['text']=ちわわんニュース紙 is out! http://bit.ly/gUy9AQ ▸ Top stories today via @mynews_bot01 @madame_sachi @whitypapa @chihuahua_news json[status]['in_reply_to_status_id']= json[status]['created_at']=Wed May 25 07:35:45 +0000 2011 json[status]['place']= json[status]['in_reply_to_user_id']= json[status]['id']=7.32911450982E+16 json[status]['source']=Paper.li json[status]['favorited']= json[status]['in_reply_to_status_id_str']= json[status]['coordinates']= json[status]['geo']= json[status]['retweet_count']=0 json[follow_request_sent]= json[verified]= json[friends_count]=526 json[favourites_count]=441 json[profile_link_color]=f2afcf json[id]=7948862 json[contributors_enabled]= json[profile_sidebar_border_color]=8350a1 json[show_all_inline_media]=1 json[geo_enabled]=1 json[time_zone]=Tokyo json[listed_count]=51 json[following]= json[profile_use_background_image]=1
account/update_profile_image
認証ユーザーのプロフィール画像を設定(要認証)
2009/7/18
http://api.twitter.com/1/account/update_profile_image.[xml|json]
認証ユーザーのプロフィール画像を設定します。
パラメーター
パラメーター | 説明 | |
---|---|---|
image | 必須 | GIF、JPG、PNG形式の画像を指定。700KB以内。 画像の幅が500px以上の場合は、縮小されます。 アニメーションGIFの場合は、最初のフレームの静止画像になります。 |
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/update_profile_image.json?include_entities=true |
account/update_profile_background_image
認証ユーザーのプロフィールの背景画像を更新(要認証)
2009/7/18
http://api.twitter.com/1/account/update_profile_background_image.[xml|json]
認証ユーザーのプロフィールの背景画像を設定します。
パラメーター
パラメーター | 説明 | |
---|---|---|
image | 必須 | GIF、JPG、PNG形式の画像を指定。800KB以内。 画像の幅は2048以上の場合は、縮小されます。 |
tile | 任意 | TRUEを指定するとタイル上に背景画像が敷き詰められます。 |
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/update_profile_background_image.json?include_entities=true |
account/update_profile
認証ユーザーのプロフィールの情報を更新(要認証)
2009/7/18
http://api.twitter.com/1/account/update_profile.[xml|json]
認証ユーザーの設定画面にある「プロフィール」タブで設定可能な各種情報(名前、位置情報、Web、自己紹介)を設定します。 設定後のユーザー情報が返ります。
パラメーター
パラメーター | 説明 | |
---|---|---|
name | 任意 |
ユーザー名。20文字以内。 例)http://api.twitter.com/1/account/update_profile.json?name=つんこ |
url | 任意 |
WebサイトのURL。100文字以内。先頭のhttp://を除いた文字列を指定。 例)http://api.twitter.com/1/account/update_profile.json?url=phpjavascriptroom.com |
location | 任意 |
現在地。30文字以内。 例)http://api.twitter.com/1/account/update_profile.json?location=Tokyo, Japan |
description | 任意 |
自己紹介。160文字以内(全角80文字以内)。 例)http://api.twitter.com/1/account/update_profile.json?description=うぇぶらー |
include_entities | 任意 |
ステータス情報に'entities'を含める場合は、true,t,1のいずれかを指定。 例)http://api.twitter.com/1/account/update_profile.json?include_entities=true |
取得サンプル(認証なし)(XML/JSON)
<?xml version="1.0" encoding="UTF-8"?> <user> <id>55984769</id> <name>つんこ</name> <screen_name>pjroomer</screen_name> <location>Tokyo, Japan</location> <description>てすあか</description> <profile_image_url>http://a0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png</profile_image_url> <url>http://phpjavascriptroom.com</url> <protected>false</protected> <followers_count>8</followers_count> <profile_background_color>C0DEED</profile_background_color> <profile_text_color>ff6699</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color> <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color> <friends_count>189</friends_count> <created_at>Sun Jul 12 01:37:21 +0000 2009</created_at> <favourites_count>99</favourites_count> <utc_offset>32400</utc_offset> <time_zone>Tokyo</time_zone> <profile_background_image_url>http://a0.twimg.com/images/themes/theme1/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <profile_use_background_image>true</profile_use_background_image> <notifications>false</notifications> <geo_enabled>true</geo_enabled> <verified>false</verified> <following>false</following> <statuses_count>1425</statuses_count> <lang>ja</lang> <contributors_enabled>false</contributors_enabled> <follow_request_sent>false</follow_request_sent> <listed_count>4</listed_count> <show_all_inline_media>false</show_all_inline_media> <default_profile>false</default_profile> <default_profile_image>true</default_profile_image> <is_translator>false</is_translator> <status> <created_at>Wed May 25 08:47:15 +0000 2011</created_at> <id>73309139866095617</id> <text>あいうえお</text> <source><a href="http://twitterapi01.appspot.com" rel="nofollow">Tw API test</a></source> <truncated>false</truncated> <favorited>false</favorited> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <in_reply_to_screen_name></in_reply_to_screen_name> <retweet_count>0</retweet_count> <retweeted>false</retweeted> <geo/> <coordinates/> <place/> <contributors/> </status> </user>
json[listed_count]=4 json[profile_background_color]=C0DEED json[protected]= json[profile_background_image_url]=http://a0.twimg.com/images/themes/theme1/bg.png json[followers_count]=8 json[location]=Tokyo, Japan json[name]=つんこ json[show_all_inline_media]= json[notifications]= json[profile_image_url]=http://a0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png json[id_str]=55984769 json[geo_enabled]=1 json[utc_offset]=32400 json[profile_text_color]=ff6699 json[url]=http://phpjavascriptroom.com json[is_translator]= json[default_profile_image]=1 json[profile_sidebar_fill_color]=DDEEF6 json[description]=てすあか json[screen_name]=pjroomer json[contributors_enabled]= json[lang]=ja json[profile_background_tile]= json[created_at]=Sun Jul 12 01:37:21 +0000 2009 json[friends_count]=189 json[status]['in_reply_to_screen_name']= json[status]['in_reply_to_user_id_str']= json[status]['contributors']= json[status]['retweeted']= json[status]['truncated']= json[status]['id_str']=73309139866095617 json[status]['text']=あいうえお json[status]['in_reply_to_status_id']= json[status]['created_at']=Wed May 25 08:47:15 +0000 2011 json[status]['place']= json[status]['in_reply_to_user_id']= json[status]['id']=7.33091398661E+16 json[status]['source']=Tw API test json[status]['favorited']= json[status]['in_reply_to_status_id_str']= json[status]['coordinates']= json[status]['geo']= json[status]['retweet_count']=0 json[verified]= json[follow_request_sent]= json[favourites_count]=99 json[profile_link_color]=0084B4 json[id]=55984769 json[default_profile]= json[statuses_count]=1425 json[profile_sidebar_border_color]=C0DEED json[time_zone]=Tokyo json[following]= json[profile_use_background_image]=1