<?php
$handle = fopen("https://graph.facebook.com/[email protected]&type=user&access_token=2227472222|2.mLWDqcUsekDYK_FQQXYnHw__.3600.1279803900-100001310000000|YxS1eGhjx2rpNYzzzzzzzLrfb5hMc.", "rb");
$json = stream_get_contents($handle);
fclose($handle);
echo $json;
$obj = json_decode($json);
print $obj->{'id'};
?>
這裏是JSON:{"data":[{"name":"Sinan \u00d6zcan","id":"610914868"}]}
PHP:JSON解碼問題
它的回聲,但JSON我無法打印ID。
我也試過:
<?php
$obj = json_decode($json);
$obj = $obj->{'data'};
print $obj->{'id'};
?>
a)而不是fopen/stream_get_contents/fclose,爲什麼不使用'$ json = file_get_contents($ url);'? b)看看'var_dump($ obj)',也許它會有所幫助。 – NikiC 2010-07-22 12:17:52