とある1ページ完結の個人サイトを作っています。
その中で、TwitterのREST APIを利用してその個人のツイートを取得する必要があります。
TwitterOAuthというライブラリを利用して、ローカルではとくに難なく作成できました。
それをレンタルサーバーにアップした際に、動かなくなってしまいました。
どこに原因があるか、お分かりになりますでしょうか?
もしくはどのような情報がわかれば、解決の糸口になりますでしょうか?
なおクライアントさんの意向で、利用しているレンタルサーバーのサービス名やスペックは不明です。
※FTP接続に必要な最低限の情報のみいただいて作業している
※phpinfo()は動きました(PHP5.5でした)
ローカル、レンタルサーバー上ともに、以下のようなコードで実現しています。
lang
1require '/twitteroauth/autoloader.php'; 2use Abraham\TwitterOAuth\TwitterOAuth; 3 4$connection = new TwitterOAuth( 5 CONSUMER_KEY, 6 CONSUMER_SECRET, 7 ACCESS_TOKEN, 8 ACCESS_TOKEN_SECRET 9); 10 11// var_dump($connection); 12 13$statues = $connection->get('statuses/user_timeline', array( 14 'user_id' => $user_id, 15 'screen_name' => $screen_name, 16 'count' => 5, 17)); 18 19// $statuesをforeachで回して出力
コメントアウトしてある部分でダンプすると、以下の様な結果が返ってきます。
lang
1object(Abraham\TwitterOAuth\TwitterOAuth)#24 (16) { 2 ["timeout":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 3 int(5) 4 ["connectionTimeout":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 5 int(5) 6 ["decodeJsonAsArray":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 7 bool(false) 8 ["userAgent":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 9 string(40) "TwitterOAuth (+https://twitteroauth.com)" 10 ["proxy":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 11 array(0) { 12 } 13 ["lastApiPath":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 14 NULL 15 ["lastHttpCode":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 16 NULL 17 ["lastHttpHeaders":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 18 array(0) { 19 } 20 ["lastHttpInfo":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 21 array(0) { 22 } 23 ["lastHttpMethod":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 24 NULL 25 ["lastXHeaders":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 26 array(0) { 27 } 28 ["lastResponse":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 29 array(0) { 30 } 31 ["bearer":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 32 NULL 33 ["consumer":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 34 object(Abraham\TwitterOAuth\Consumer)#30 (3) { 35 ["key"]=> 36 string(25) "xxxxxxxxxxxxxxxxxxxxxxxxx" // ←実際はコンシューマキーが入っています 37 ["secret"]=> 38 string(50) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // ←実際はコンシューマシークレットが入っています 39 ["callbackUrl"]=> 40 NULL 41 } 42 ["token":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 43 object(Abraham\TwitterOAuth\Token)#29 (2) { 44 ["key"]=> 45 string(50) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // ←実際はアクセストークンが入っています 46 ["secret"]=> 47 string(45) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // ←実際はアクセストークンシークレットが入っています 48 } 49 ["signatureMethod":"Abraham\TwitterOAuth\TwitterOAuth":private]=> 50 object(Abraham\TwitterOAuth\HmacSha1)#31 (0) { 51 } 52}
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/02/24 01:19
2015/02/24 01:33
2015/02/25 10:35