用 php 解码 json - 从 Facebook 个人资料图片中获取 url
decoding json with php - get url from Facebook profile pic
我需要使用 PHP 解码此 json 值。我需要值 'url'.
这是我有但不起作用的方法。
$json = file_get_contents('http://graph.facebook.com/{fb-ID}/picture?type=large&redirect=false');
$decoded = json_decode($json,true);
$url = $decoded[???]; // NEED THIS VAR.
由于 $decoded
是一个 PHP 数组,您可以像访问任何其他数组一样访问它:
$url = $decoded['data']['url'];
$decoded=(object)json_decode( $json['data'], true );
echo $decoded->url
这有效:
$json = file_get_contents('http://graph.facebook.com/{fb-ID}/picture?type=large&redirect=false');
$decoded = json_decode($json,true);
$url = $decoded['data']['url'];
我需要使用 PHP 解码此 json 值。我需要值 'url'.
这是我有但不起作用的方法。
$json = file_get_contents('http://graph.facebook.com/{fb-ID}/picture?type=large&redirect=false');
$decoded = json_decode($json,true);
$url = $decoded[???]; // NEED THIS VAR.
由于 $decoded
是一个 PHP 数组,您可以像访问任何其他数组一样访问它:
$url = $decoded['data']['url'];
$decoded=(object)json_decode( $json['data'], true );
echo $decoded->url
这有效:
$json = file_get_contents('http://graph.facebook.com/{fb-ID}/picture?type=large&redirect=false');
$decoded = json_decode($json,true);
$url = $decoded['data']['url'];