0
$args = array(
'name' => 'test',
'description' => 'xxxx',
'start_time' => 'xxxx',
'end_time' => 'xxxxx'
); 
$target_url = "https://graph.facebook.com/me/events";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$result = curl_exec($ch);
curl_close($ch);

戻り値

 {"id":"xxxx"}

この id を php の $id として使用したいので、それをさらに使用することもできます..ありがとう。

4

3 に答える 3

3

このために使用json_decodeします。次の例を確認してください。

$Object = json_decode($result);
$id = $Object->id;

echo $id; //return: xxxx

$id 変数にリセットする代わりに、いつでも $Object->id を使用できますが、それは問題ではありません。

json_decode()ドキュメント: http://us2.php.net/json_decode

于 2012-11-29T14:21:11.433 に答える
0

あなたが言っていることを理解しているかどうかはわかりませんが、IDの値を取得する方法を求めている場合は、いつでも次のことを行うことができます

$_GET["id"] if GET Request was sent

$_POST["id"] if POST Request was sent
于 2012-11-29T14:21:35.473 に答える
0
<?php
$obj = json_decode($result);
$id = $obj->id;
echo $id;
?>
于 2012-11-29T14:22:42.007 に答える