我想在我的PHP页面中传递授权令牌。 我使用的代码是如下:如何通过授权令牌在php
function getValues(){
$path='webservice path';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic token_no'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Access-Control-Allow-Origin: *'));
$retValue = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $retValue;
}
但我不能够以包括报头。 请帮我解决这个问题。
什么问题?你得到什么错误?你期望得到什么?什么是授权值('Basic token_no'会导致错误)?请提出一个问题。 –
http://stackoverflow.com/questions/8753195/php-curl-header –
其实我得到401错误的Web服务调用 – amrita