0

私は何年もインターネットを検索してきましたが、この問題の解決策を見つけることができませんでした。

$follow = $_GET['follow'];
$following = $_GET['following'];

session_start();

if(!empty($_SESSION['username'])){
$twitteroauth = new TwitterOAuth('MY PRIVATE CODE', 'MY PRIVATE CODE', $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
}

$follow_timeline = $twitteroauth->get('followers/ids', array('screen_name' => $follow));
$following_timeline = $twitteroauth->get('friends/ids', array('screen_name' =>     $following));

if (in_array($following, $follow_timeline)) {
echo "We found the word!";
}

jsonファイルからのデータです。これも読めます。https://dev.twitter.com/docs/api/1/get/friends/ids & https://dev.twitter.com/docs/api/1/get/followers/ids . 上記のスクリプトを実行すると、このエラーが表示されます。

in_array() [function.in-array]: Wrong datatype for second argument in

そして、前にjsonデコードを使用することを考えましたif (in_array($following, $follow_timeline))が、このエラーが表示されます。

json_decode() expects parameter 1 to be string, object given in

誰か助けてください。私はPHPを始めたばかりで、少し混乱していました。

4

2 に答える 2

0

in_array() のドキュメントを確認してください ....http://php.net/manual/en/function.in-array.php

2 番目のパラメーター ($follow_timeline) は配列でなければなりません... $twitteroauth->get() メソッドが配列を返すことは確かですか?

于 2012-10-15T19:24:10.830 に答える
0

を定義します$following_timelineが、使用しようとします$follow_timeline

于 2012-10-15T19:19:25.917 に答える