需要通过将参数传递给标头来获取服务器的响应

时间:2016-07-15 11:02:11

标签: php curl

我希望通过将参数传递给标头来响应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 ;
?>

但我得到一个空白页面作为回应。我做错了哪里?

0 个答案:

没有答案