I'm using tmhOAuth library to parse twitter stream in php.
It returned me variable $data with this object
object sample for stackoverflow
{
"created_at":"Wed Jan 02 13:37:54 +0000 2013",
"id":286466350610776064,
"id_str":"286466350610776064",
...
}
looks like simple object, but how pull some data from this object?
$data->created_at doesn't work, it broke my head, why??
Isn't it because probably you don't see that this is a string containing Json and you need to decode it first otherwise it's just a string variable and not an object?
See json_decodeDocs:
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With