Post data to api return json result

<?php 
	$url = http://127.0.0.1/api.php;

	$token = "398cfd96a89a5f45fac326b6778f5da4";
	$agent = $_SERVER['HTTP_USER_AGENT'];

	// POST ITEM
	$query = array(
		"access_token" => $token, 
		"memberID" => "00000001",
	);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch,CURLOPT_USERAGENT, $agent);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, count($query));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
	$result = curl_exec($ch);
	curl_close($ch);
	$result = json_decode($result, true);

	echo "<pre>";
	print_r($result);
	echo "</pre>";
?>

發表迴響