im requesting information from the instagram api in php like this:
<?php $relation = $instagram->get('users/'.$item->id.'/relationship');
..
which return this json data array for me:
object(stdClass)#58(2){
[
"meta"
]=>object(stdClass)#59(1){
[
"code"
]=>int(200)
}[
"data"
]=>object(stdClass)#60(3){
[
"outgoing_status"
]=>string(7)"follows"[
"target_user_is_private"
]=>bool(true)[
"incoming_status"
]=>string(4)"none"
}
}
note: i used var_dump($relation) to bring this out
what I'm trying to do is loop through this array and display the outgoing status and the incoming status ie
loop(json-array){
echo outgoing_status;
echo incoming_status;
}
thank you very much..
You have an object (instance of stdClass
, the generic object), not an array.
$outgoing_status = $response->data->outgoing_status;
$incoming_status = $response->data->incoming_status;
As a side note, use json_decode($json, TRUE)
to return the data as an associative array instead of an object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.