我为客户详细信息创建了一个Web API服务。我如何获得令牌和动词PUT,DELETE,PATCH和GET来验证API调用并提供该信息。?
$URL = 'http://localhost/rest_api_project1/customer-api/v1/user/A2/items';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); //Post Fields
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//--Setting header.
$headers = array();
$headers[] = 'X-Apple-Tz: 0';
$headers[] = 'X-Apple-Store-Front: 143444,12';';
$headers[] = 'Host: www.example.com';
$headers[] = 'Referer: http://www.example.com/index.php'; //Your referrer address
$headers[] = 'Token: asf987a9sdf89asd989879asdf98as7d9-sadf8asd-sdf8a9088a';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec($ch);
curl_close($ch);
print $server_output;