PHP TwitterAPI ツイートを取得

ツイートを取得する時のめもです

できたもの

https://zenryokuservice.com/mokuhyoAP.php

ツイート表示のためのテンプレートHTML

取得もとはこちら(Twitter/publish?)

ツイート取得時のJSONの中身

ツイートの取得時に「json_decode()」を使用します。というか使用していました。それはここからTwitterAPIPHPラッパークラスにあるコードを使わせてもらったからです。
そして、案の定手こずりました。以下は取得したJSONのプロパティ一覧です。

["truncated"]=> bool(false) 
["entities"]=> object(stdClass)#5722 (4) { 
    ["hashtags"]=> array(0) { } 
    ["symbols"]=> array(0) { } 
    ["user_mentions"]=> array(0) { } 
    ["urls"]=> array(1) { 
        [0]=> object(stdClass)#5723 (4) { 
            ["url"]=> string(23) "https://t.co/ucfr5Mp3pk" 
            ["expanded_url"]=> string(37) "https://zenryokuservice.com/mokuhyoAP" 
            ["display_url"]=> string(29) "zenryokuservice.com/mokuhyoAP" 
            ["indices"]=> array(2) { [0]=> int(75) [1]=> int(98) } 
        } 
    } 
} 

["metadata"]=> object(stdClass)#5724 (2) { 
    ["iso_language_code"]=> string(2) "ja" 
    ["result_type"]=> string(6) "recent" 
} 

["source"]=> string(82) "Twitter for iPhone" 
["in_reply_to_status_id"]=> NULL 
["in_reply_to_status_id_str"]=> NULL 
["in_reply_to_user_id"]=> NULL 
["in_reply_to_user_id_str"]=> NULL 
["in_reply_to_screen_name"]=> NULL 
["user"]=> object(stdClass)#5725 (41) { 
    ["id"]=> int(2378007752) 
    ["id_str"]=> string(10) "2378007752" 
    ["name"]=> string(12) "たくのじ" 
    ["screen_name"]=> string(13) "java_takunoji" 
    ["location"]=> string(0) "" 
    ["description"]=> string(288) "JavaでRPIなどの上で動くゲームを仕様から作成中。 好きな言葉は「ロッケンロールは1日にして成らず」#PGボックス #Java #opencv Create a game based java on RPi etc ... My favorite word is “ロッケンロールは1日にして成らず” thanks!" 
    ["url"]=> string(23) "https://t.co/tYxRX8YCof" 
    ["entities"]=> object(stdClass)#5726 (2) { 
        ["url"]=> object(stdClass)#5727 (1) { 
            ["urls"]=> array(1) { 
                [0]=> object(stdClass)#5728 (4) { 
                    ["url"]=> string(23) "https://t.co/tYxRX8YCof" 
                    ["expanded_url"]=> string(39) "https://zenryokuservice.com/roadMap.php" 
                    ["display_url"]=> string(31) "zenryokuservice.com/roadMap.php" 
                    ["indices"]=> array(2) { [0]=> int(0) [1]=> int(23) } 
                } 
            } 
        }
    ["description"]=> object(stdClass)#5729 (1) { 
        ["urls"]=> array(0) { } 
    } 
} 

["protected"]=> bool(false) 
["followers_count"]=> int(1756) 
["friends_count"]=> int(3297) 
["listed_count"]=> int(1) 
["created_at"]=> string(30) "Sat Mar 08 02:49:23 +0000 2014" 
["favourites_count"]=> int(5035) 
["utc_offset"]=> NULL ["time_zone"]=> NULL 
["geo_enabled"]=> bool(true) 
"verified"]=> bool(false) 
["statuses_count"]=> int(957) 
["lang"]=> string(2) "ja" 
["contributors_enabled"]=> bool(false) 
["is_translator"]=> bool(false) 
["is_translation_enabled"]=> bool(false) 
["profile_background_color"]=> string(6) "C0DEED" 
["profile_background_image_url"]=> string(48) "http://abs.twimg.com/images/themes/theme1/bg.png" ["profile_background_image_url_https"]=> string(49) "https://abs.twimg.com/images/themes/theme1/bg.png" ["profile_background_tile"]=> bool(false) 
["profile_image_url"]=> string(74) "http://pbs.twimg.com/profile_images/976105570573762560/jqMlT-a__normal.jpg" ["profile_image_url_https"]=> string(75) "https://pbs.twimg.com/profile_images/976105570573762560/jqMlT-a__normal.jpg" ["profile_link_color"]=> string(6) "1DA1F2" 
["profile_sidebar_border_color"]=> string(6) "C0DEED" 
["profile_sidebar_fill_color"]=> string(6) "DDEEF6" 
["profile_text_color"]=> string(6) "333333" 
["profile_use_background_image"]=> bool(true) 
["has_extended_profile"]=> bool(false) 
["default_profile"]=> bool(true) 
["default_profile_image"]=> bool(false) 
["following"]=> bool(false) 
"follow_request_sent"]=> bool(false) 
["notifications"]=> bool(false) 
["translator_type"]=> string(4) "none" } 
["geo"]=> NULL ["coordinates"]=> NULL 
["place"]=> NULL ["contributors"]=> NULL 
["is_quote_status"]=> bool(false) 
["retweet_count"]=> int(0) 
["favorite_count"]=> int(2) 
["favorited"]=> bool(false) 
["retweeted"]=> bool(false) 
["possibly_sensitive"]=> bool(false) 
["lang"]=> string(2) "ja" 
}

まぁ全部使わないのでここら辺にしておきます。

でわでわ。。。










投稿者:

takunoji

音響、イベント会場設営業界からIT業界へ転身。現在はJava屋としてサラリーマンをやっている。自称ガテン系プログラマー(笑) Javaプログラミングを布教したい、ラスパイとJavaの相性が良いことに気が付く。 Spring framework, Struts, Seaser, Hibernate, Playframework, JavaEE6, JavaEE7などの現場経験あり。 SQL, VBA, PL/SQL, コマンドプロント, Shellなどもやります。

コメントを残す