如何通过php读取JSON响应

I got the JSON response from Facebook. How to retrieve the value of $id & $post_id?

    $response = json_decode ( file_get_contents($graph_url) );
    $id = $response.id;
    $post_id = $response.post_id;    

        print_r( $response );   
        print_r( $id );
        print_r( $post_id );

Outputs:

stdClass Object ( [id] => 232160686920835 [post_id] => 231794566957447_232160693587501 )

No output of $id & $post_id ... ...

Your object syntax is wrong. Use:

$id = $response->id;
$post_id = $response->post_id;    

print_r( $response );   
print_r( $id );
print_r( $post_id );

Or if you prefer to work with arrays, you can put true as the second argument for json_decode:

$response = json_decode ( file_get_contents($graph_url), true );
$id = $response['id'];
$post_id = $response['post_id'];    

print_r( $response );   
print_r( $id );
print_r( $post_id );

In PHP OOP

-> is used instead of . like in Java or other languages.