[英]Getting only the message of the status facebook php API
I'm using the Facebook php api. 我正在使用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. 获取
raw_response
和json_decode
以获取消息。 This is assuming that you are querying for a single status. 这假设您正在查询单个状态。 For multiple from a feed, you have to loop through the
data
element. 对于来自Feed的多个,您必须遍历
data
元素。
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'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.