2013年10月1日火曜日

GET friendships/lookup

<?php
include_once('../oauth/start.php');
/*
Friends & Followers
GET friendships/lookup
https://dev.twitter.com/docs/api/1.1/get/friendships/lookup
HTTP Methods GET

http://www.tryphp.net/2012/01/24/phpapptwitter-friendships_lookup/

 */

echo '<pre>';
$apiurl='https://api.twitter.com/1.1/friendships/lookup.json';
$HTTP_Methods='GET';
$paras['screen_name']='';
$paras['user_id']=rawurlencode('783214,6253282');

$x->twoauth($HTTP_Methods,$apiurl,$paras);
//$x->send_curl();
//var_dump($x->send_curl());
print_r($x->send_curl());

?>



Array
(
    [0] => stdClass Object
        (
            [name] => Twitter
            [screen_name] => twitter
            [id] => 783214
            [id_str] => 783214
            [connections] => Array
                (
                    [0] => none
                )

        )

    [1] => stdClass Object
        (
            [name] => Twitter API
            [screen_name] => twitterapi
            [id] => 6253282
            [id_str] => 6253282
            [connections] => Array
                (
                    [0] => none
                )

        )

)




配列を利用する;






 $us=array('159536039,1185244459,1034053130,748788386,780785840,177437663,565343646,805594118');
 $paras['user_id']=rawurlencode(implode(',',$us));



2013年9月29日日曜日

Twitter Errors

[errors] => sharing is not permissible for this status (Share validations failed)




stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 195
                    [message] => Missing or invalid url parameter.
                )

        )

)




stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [message] => Bad Authentication data
                    [code] => 215
                )

        )

)




stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 25
                    [message] => Query parameters are missing.
                )

        )

)

stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 158
                    [message] => You can't follow yourself
                )

        )

)
stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [message] => Sorry, that page does not exist
                    [code] => 34
                )

        )

)
stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [message] => Rate limit exceeded
                    [code] => 88
                )

        )

)

POST statuses/destroy/:id

<?php
include_once('../oauth/start.php');
/*
Twitter
POST statuses/destroy/:id
https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid
https://api.twitter.com/1.1/statuses/destroy/:id.json
HTTP Methods POST

 */

echo '<pre>';
$apiurl='https://api.twitter.com/1.1/statuses/destroy/382527698498621440.json';
$HTTP_Methods='POST';
$paras['id']='';
$paras['trim_user']='true';


$x->twoauth($HTTP_Methods,$apiurl,$paras);
//$x->send_curl();
//var_dump($x->send_curl());
print_r($x->send_curl());

?>



stdClass Object
(
    [geo] => 
    [entities] => stdClass Object
        (
            [urls] => Array
                (
                )

            [hashtags] => Array
                (
                )

            [user_mentions] => Array
                (
                )

        )

    [user] => stdClass Object
        (
            [id] => 371259452
            [id_str] => 371259452
        )

    [in_reply_to_user_id] => 
    [contributors] => 
    [place] => 
    [retweet_count] => 0
    [source] => ツイッターの種
    [in_reply_to_status_id_str] => 
    [coordinates] => 
    [retweeted] => 
    [id] => 3.82527698499E+17
    [in_reply_to_user_id_str] => 
    [in_reply_to_status_id] => 
    [truncated] => 
    [in_reply_to_screen_name] => 
    [created_at] => Tue Sep 24 15:31:25 +0000 2013
    [id_str] => 382527698498621440
    [text] => 福島県漁連 試験操業を再開へ
    [favorited] => 
)

GET statuses/retweets/:id

$apiurl='https://api.twitter.com/1.1/statuses/retweets/373439054957670401.json';
$HTTP_Methods='GET';
$paras['id']=''; //id.json
$paras['count']='1';
$paras['trim_user']='true';


$x->twoauth($HTTP_Methods,$apiurl,$paras);
//$x->send_curl();
//var_dump($x->send_curl());
print_r($x->send_curl());



Array
(
    [0] => stdClass Object
        (
            [created_at] => Sun Sep 29 01:37:32 +0000 2013
            [id] => 3.84129784651E+17
            [id_str] => 384129784650801152
            [text] => RT @masason: 被災地高校生の留学支援「TOMODACHIリーダーシップ・プログラム」に参加した100人が無事帰国。米国での学びと被災地の現状を9/1(日)13:30~アップルストア銀座にて報告します。ぜひ高校生の生の声を聞きに来て下さい。
            [source] => Twitter for iPhone
            [truncated] => 
            [in_reply_to_status_id] => 
            [in_reply_to_status_id_str] => 
            [in_reply_to_user_id] => 
            [in_reply_to_user_id_str] => 
            [in_reply_to_screen_name] => 
            [user] => stdClass Object
                (
                    [id] => 118879992
                    [id_str] => 118879992
                )

            [geo] => 
            [coordinates] => 
            [place] => 
            [contributors] => 
            [retweeted_status] => stdClass Object
                (
                    [created_at] => Fri Aug 30 13:36:23 +0000 2013
                    [id] => 3.73439054958E+17
                    [id_str] => 373439054957670401
                    [text] => 被災地高校生の留学支援「TOMODACHIリーダーシップ・プログラム」に参加した100人が無事帰国。米国での学びと被災地の現状を9/1(日)13:30~アップルストア銀座にて報告します。ぜひ高校生の生の声を聞きに来て下さい。
                    [source] => TwitRocker2 for iPad
                    [truncated] => 
                    [in_reply_to_status_id] => 
                    [in_reply_to_status_id_str] => 
                    [in_reply_to_user_id] => 
                    [in_reply_to_user_id_str] => 
                    [in_reply_to_screen_name] => 
                    [user] => stdClass Object
                        (
                            [id] => 99008565
                            [id_str] => 99008565
                        )

                    [geo] => 
                    [coordinates] => 
                    [place] => 
                    [contributors] => 
                    [retweet_count] => 247
                    [favorite_count] => 104
                    [entities] => stdClass Object
                        (
                            [hashtags] => Array
                                (
                                )

                            [symbols] => Array
                                (
                                )

                            [urls] => Array
                                (
                                )

                            [user_mentions] => Array
                                (
                                )

                        )

                    [favorited] => 
                    [retweeted] => 
                    [lang] => ja
                )

            [retweet_count] => 247
            [favorite_count] => 0
            [entities] => stdClass Object
                (
                    [hashtags] => Array
                        (
                        )

                    [symbols] => Array
                        (
                        )

                    [urls] => Array
                        (
                        )

                    [user_mentions] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [screen_name] => masason
                                    [name] => 孫正義
                                    [id] => 99008565
                                    [id_str] => 99008565
                                    [indices] => Array
                                        (
                                            [0] => 3
                                            [1] => 11
                                        )

                                )

                        )

                )

            [favorited] => 
            [retweeted] => 
            [lang] => ja
        )

)

Twitter API optional trim_user

$apiurl='https://api.twitter.com/1.1/statuses/user_timeline.json';
$HTTP_Methods='GET';
$paras['user_id']='';
$paras['screen_name']='';
$paras['since_id']='382527698498621440';
$paras['count']='';
$paras['page']='';
$paras['max_id']='383209620551921666';
$paras['trim_user']='true';
$paras['include_entities']='true';
$paras['exclude_replies']='true';
$paras['contributor_details']='true';
$paras['include_rts']='true';

$x->twoauth($HTTP_Methods,$apiurl,$paras);
//$x->send_curl();
//var_dump($x->send_curl());
print_r($x->send_curl());


例  trim_user = true
Array
(
    [0] => stdClass Object
        (
            [created_at] => Thu Sep 26 12:41:07 +0000 2013
            [id] => 3.83209620552E+17
            [id_str] => 383209620551921666
            [text] => 楽天Vなるか、9回マー君登場
            [source] => ツイッターの種
            [truncated] => 
            [in_reply_to_status_id] => 
            [in_reply_to_status_id_str] => 
            [in_reply_to_user_id] => 
            [in_reply_to_user_id_str] => 
            [in_reply_to_screen_name] => 
            [user] => stdClass Object
                (
                    [id] => 371259452
                    [id_str] => 371259452
                )

            [geo] => 
            [coordinates] => 
            [place] => 
            [contributors] => 
            [retweet_count] => 0
            [favorite_count] => 0
            [entities] => stdClass Object
                (
                    [hashtags] => Array
                        (
                        )

                    [symbols] => Array
                        (
                        )

                    [urls] => Array
                        (
                        )

                    [user_mentions] => Array
                        (
                        )

                )

            [favorited] => 
            [retweeted] => 
            [lang] => ja
        )

)

例  trim_user = false

Array
(
    [0] => stdClass Object
        (
            [created_at] => Thu Sep 26 12:41:07 +0000 2013
            [id] => 3.83209620552E+17
            [id_str] => 383209620551921666
            [text] => 楽天Vなるか、9回マー君登場
            [source] => ツイッターの種
            [truncated] => 
            [in_reply_to_status_id] => 
            [in_reply_to_status_id_str] => 
            [in_reply_to_user_id] => 
            [in_reply_to_user_id_str] => 
            [in_reply_to_screen_name] => 
            [user] => stdClass Object
                (
                    [id] => 371259452
                    [id_str] => 371259452
                    [name] => 黒(hei)
                    [screen_name] => hei6321
                    [location] => 日本
                    [description] => 始めまして、黒です。これからもTwitterで一緒にYahooApiを遊ぼう!!!. http://t.co/GbOnNHxhTg
                    [url] => http://t.co/fw9Qmf2t3W
                    [entities] => stdClass Object
                        (
                            [url] => stdClass Object
                                (
                                    [urls] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [url] => http://t.co/fw9Qmf2t3W
                                                    [expanded_url] => http://apiyahoo.hp2.jp/
                                                    [display_url] => apiyahoo.hp2.jp
                                                    [indices] => Array
                                                        (
                                                            [0] => 0
                                                            [1] => 22
                                                        )

                                                )

                                        )

                                )

                            [description] => stdClass Object
                                (
                                    [urls] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [url] => http://t.co/GbOnNHxhTg
                                                    [expanded_url] => http://loto6.pa.land.to/
                                                    [display_url] => loto6.pa.land.to
                                                    [indices] => Array
                                                        (
                                                            [0] => 43
                                                            [1] => 65
                                                        )

                                                )

                                        )

                                )

                        )

                    [protected] => 
                    [followers_count] => 1677
                    [friends_count] => 1825
                    [listed_count] => 0
                    [created_at] => Sat Sep 10 14:13:36 +0000 2011
                    [favourites_count] => 22
                    [utc_offset] => 32400
                    [time_zone] => Tokyo
                    [geo_enabled] => 1
                    [verified] => 
                    [statuses_count] => 2569
                    [lang] => ja
                    [contributors_enabled] => 
                    [is_translator] => 
                    [profile_background_color] => C0DEED
                    [profile_background_image_url] => http://abs.twimg.com/images/themes/theme1/bg.png
                    [profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme1/bg.png
                    [profile_background_tile] => 
                    [profile_image_url] => http://a0.twimg.com/profile_images/3175354807/63967ddad879ead7bae40d178cf1ebb2_normal.png
                    [profile_image_url_https] => https://si0.twimg.com/profile_images/3175354807/63967ddad879ead7bae40d178cf1ebb2_normal.png
                    [profile_banner_url] => https://pbs.twimg.com/profile_banners/371259452/1357434745
                    [profile_link_color] => 0084B4
                    [profile_sidebar_border_color] => C0DEED
                    [profile_sidebar_fill_color] => DDEEF6
                    [profile_text_color] => 333333
                    [profile_use_background_image] => 1
                    [default_profile] => 1
                    [default_profile_image] => 
                    [following] => 
                    [follow_request_sent] => 
                    [notifications] => 
                )

            [geo] => 
            [coordinates] => 
            [place] => 
            [contributors] => 
            [retweet_count] => 0
            [favorite_count] => 0
            [entities] => stdClass Object
                (
                    [hashtags] => Array
                        (
                        )

                    [symbols] => Array
                        (
                        )

                    [urls] => Array
                        (
                        )

                    [user_mentions] => Array
                        (
                        )

                )

            [favorited] => 
            [retweeted] => 
            [lang] => ja
        )

)

Twitter API optional since_id max_id

Twitter API optional


*
*
*
*
*
*  since_id     より↑のツイートを表示
*  max_id      より↓のツイートを表示
*
*
*
*
*
*
*
*

GET statuses/user_timeline

<?php
include_once('../oauth/start.php');
/*
Timelines
GET statuses/user_timeline
https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
HTTP Methods GET

認証ユーザーのステータス情報(各つぶやきとそれに関連する諸々の情報)の最大3200件分から最新20件
(count引数指定で最大200件)を取得します。 screen_name や user_id のパラメータを指定すれば
他のユーザーのステータス情報を取得できます。ただしそのユーザー情報が非表示設定されていない場合か、
認証ユーザーからのフォローリクエストを承諾している場合に限ります。返されたタイムラインは、Twitter.com
にログインするときにユーザー自身が見るのと同じタイムライン情報です。このメソッドは、最大3200件まで
ステータス情報を返します。include_rts が true または 1 になっていれば、リツイートも含めて最大
3200件のステータス情報を返します。

このメソッドは、include_rtsパラメータが設定されていない限り、XMLとJSON形式において、リツイートの
つぶやきは含まれません。RSSとAtom形式の場合は、常にステータス情報にリツイートが含まれます。

http://www.tryphp.net/2012/01/10/phpapptwitter-user_timeline/
http://twinavi.jp/guide/section/twitter/glossary/メンション(Mentions)とは

 */

echo '<pre>';
$apiurl='https://api.twitter.com/1.1/statuses/user_timeline.json';
$HTTP_Methods='GET';
$paras['user_id']='';
$paras['screen_name']='masason';
$paras['since_id']='371636752991010817';
$paras['count']='';
$paras['page']='';
$paras['max_id']='';
$paras['trim_user']='true';
$paras['include_entities']='true';
$paras['exclude_replies']='';
$paras['contributor_details']='';
$paras['include_rts']='';

$x->twoauth($HTTP_Methods,$apiurl,$paras);
//$x->send_curl();
//var_dump($x->send_curl());
print_r($x->send_curl());

?>





Array
(
    [0] => stdClass Object
        (
            [created_at] => Fri Aug 30 13:36:23 +0000 2013
            [id] => 3.73439054958E+17
            [id_str] => 373439054957670401
            [text] => 被災地高校生の留学支援「TOMODACHIリーダーシップ・プログラム」に参加した100人が無事帰国。米国での学びと被災地の現状を9/1(日)13:30~アップルストア銀座にて報告します。ぜひ高校生の生の声を聞きに来て下さい。
            [source] => TwitRocker2 for iPad
            [truncated] => 
            [in_reply_to_status_id] => 
            [in_reply_to_status_id_str] => 
            [in_reply_to_user_id] => 
            [in_reply_to_user_id_str] => 
            [in_reply_to_screen_name] => 
            [user] => stdClass Object
                (
                    [id] => 99008565
                    [id_str] => 99008565
                )

            [geo] => 
            [coordinates] => 
            [place] => 
            [contributors] => 
            [retweet_count] => 247
            [favorite_count] => 104
            [entities] => stdClass Object
                (
                    [hashtags] => Array
                        (
                        )

                    [symbols] => Array
                        (
                        )

                    [urls] => Array
                        (
                        )

                    [user_mentions] => Array
                        (
                        )

                )

            [favorited] => 
            [retweeted] => 
            [lang] => ja
        )

)