我希望通过将参数传递给标头来响应API。这就是我所做的:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"API url goes here");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array();
$headers[] = 'auth_type:email';
$headers[] = 'user_name:testuser';
$headers[] = 'password:123456';
$headers[] = 'app_key:someapikey';
$headers[] = 'platform:platform name';
$headers[] = 'api_version: 1.0';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
print $server_output ;
?>
但我得到一个空白页面作为回应。我做错了哪里?