仅获取状态 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 以获取消息。这是假设您正在查询单个状态。对于来自提要的多个,您必须遍历 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'];
}