繁体   English   中英

只获取状态facebook php API的消息

[英]Getting only the message of the status facebook php API

我正在使用Facebook php api。 我想只获取用户状态的消息(字符串)。 在我的代码中,它返回了很多字段,但我只想获取消息字段。 我怎样才能做到这一点?

$request = new FacebookRequest($sess,'GET','/400495666788117');
$response = $request->execute();
$graph = $response->getGraphObject();

echo '<pre>' . print_r( $graph, 1 ) . '</pre>';

输出:

Facebook\GraphObject Object
(
    [backingData:protected] => Array
        (
            [id] => 400495666788117
            [from] => stdClass Object
                (
                    [id] => *******
                    [name] => *******
                )

            [message] => aaa
            [updated_time] => 2015-03-02T11:59:12+0000

获取raw_responsejson_decode以获取消息。 这假设您正在查询单个状态。 对于来自Feed的多个,您必须遍历data元素。

单身状态

   $arrayResult = json_decode($response->getRawResponse(), true);
   $message = $arrayResult['message']; 

饲料

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM