0
votes

im running the Twitter API v1.1.

        $tweets= $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=".$searchstring."&result_type=mixed&rpp=100&count=".$notweets);

        $twitter=json_encode($tweets);

        for ($i = 0; $i < sizeof($twitter["statuses"]); $i++) {
           echo $twitter["statuses"][$i];
        }

Warning: Illegal string offset 'statuses'

Why is it the wrong offset?

https://dev.twitter.com/docs/api/1.1/get/search/tweets

1

1 Answers

0
votes
    $tweets= $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=".$searchstring."&result_type=mixed&rpp=100&count=".$notweets);

    $twitter=json_encode($tweets);

    foreach($tweets->statuses as $tweet){ echo $tweet; }