我希望能够向一个URL发出cURL请求,并携带以下头信息:
'Content-Type: application/json',
'Authorization': 'Basic XXXXXXXXXX'
我已经有了下面的代码:
它显示的结果是:
如有建议或帮助,将不胜感激。
<?php
$post_url = "https://api.interlinkexpress.com/user/?action=login";
$curl = curl_init($post_url);
$headers = array(
'Content-Type: application/json',
'Authorization': 'Basic XXXXXXXXX'
);
//curl_setopt($curl, CURLOPT_USERPWD, "username":"Password");
curl_setopt($curl, CURLOPT_URL, $post_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($post_data) );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$post_response = curl_exec($curl);
?>
它显示的结果是:
这是$header数组下的'Authorization...'行。客户端发送了错误请求
如有建议或帮助,将不胜感激。