I'm using the Facebook php api. I want to get only the message (string) of the users status. In my code it's returning lots of fields but I want only to get message field. How can I do that?
$request = new FacebookRequest($sess,'GET','/400495666788117');
$response = $request->execute();
$graph = $response->getGraphObject();
echo '<pre>' . print_r( $graph, 1 ) . '</pre>';
output :
Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[id] => 400495666788117
[from] => stdClass Object
(
[id] => *******
[name] => *******
)
[message] => aaa
[updated_time] => 2015-03-02T11:59:12+0000
Get the raw_response
and json_decode
to get the message. This is assuming that you are querying for a single status. For multiple from a feed, you have to loop through the data
element.
Single status
$arrayResult = json_decode($response->getRawResponse(), true);
$message = $arrayResult['message'];
Feed
$arrayResult = json_decode($response->getRawResponse(), true);
foreach($arrayResult['data'] as $post){
$message = $post['message'];
$post_time = $post['created_time'];
}
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.