I'm not sure how to write the syntax to access "text" in the object that was returned by the twitter standard search API.
I have tried every possible combination of PHP operators that I can think of e.g. $statuses[0]->"text" etc. but I simply just get errors no matter what I do. The only thing that actually printed something to the screen was print_r($statuses).
I have tried using json_decode() but I'm unsure what to do after that. I'm not even sure if that is the correct usage of the function.
stdClass Object
(
[statuses] => Array
(
[0] => stdClass Object
(
[created_at] => Wed Jan 09 01:03:14 +0000 2019
[id] => 1082804961115885570
[id_str] => 1082804961115885570
[text] => Happy Birthday @LeslieAmandaa_ !!
That is some of print_r($statuses). I would like to access [text].
$statuses = $connection->get("search/tweets", array("q" => "birthday"));
echo "<pre>";
print_r($statuses);
echo "</pre>";
That is the PHP I used to
- Get the object from the Twitter Standard Search API
- Print it to my webpage (what you see in the screenshot)
I expect to be able to echo out just the [text] part but nothing I have tried seems to do that for me (I have looked through other threads and can't find anything that works for my particular object). I would also like to use this object with JavaScript (also jQuery) if anyone has any helpful information on how to pass that data to a JS file.
Ok so I got it to display errors on the page and the error that is likely causing this is:
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in
C:\inetpub\wwwroot\index.php:22 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\index.php on line 22