问题描述
我想为一个url设置一个请求头xyz.com
是在php中设置它的正确方法吗?
header('Authorization:AuthSub token =xxxxxx');
标题('location:https://www.google.com/accounts/AuthSubRevokeToken');
我正在尝试设置此URL的标头以进行呼叫。但授权:AuthSub标头不会显示在FireFox NET面板的请求头部分。用于显示请求。
有什么想法吗?
感谢。
我之前使用过curl,但它似乎没有发出任何请求,因为我无法在FireFox的NET面板中看到它。
代码如下:
$ curl = curl_init();
curl_setopt($ curl,CURLOPT_URL,https://www.google.com/accounts/AuthSubRevokeToken);
curl_setopt($ curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ curl,CURLOPT_FAILONERROR,true);
curl_setopt($ curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ curl,CURLOPT_HTTPHEADER,array('Authorization:AuthSub token =1 / xxx'
));
$ result = curl_exec($ curl);
curl_close($ curl);
echo'hererer'。$ result; exit;
使用CURL请求另一个页面? header()函数仅适用于Web浏览器服务器通信。它不会影响您的服务器端脚本对其他Web服务器的任何请求。为此,您需要修改您正在使用的特定方法,例如curl或streams。
有关curl,请参阅 CURLOPT_HTTPHEADER
这里:
I want to set a request header for a url xyz.comis it the right way to set it in php?
header('Authorization: AuthSub token="xxxxxx"');
header('location:https://www.google.com/accounts/AuthSubRevokeToken');
I am trying to set the header for this URL for a call.But the Authorization: AuthSub header doesnt shows up in the request headers section of the FireFox NET panel.Which is used to show the requests.
Any idea about it?Thanx.
I was using curl previously,But it didnt seemed to issue any request as i cant see it in the NET panel of FireFox.Code is as follows:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"https://www.google.com/accounts/AuthSubRevokeToken");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="1/xxx"'
));
$result = curl_exec($curl);
curl_close($curl);
echo 'hererer'.$result;exit;
A call, as in using CURL to request another page? The header() function applies only for web-browser<->server communications. It cannot affect any requests your server-side script does to other webservers. For that, you need to modify the particular method you're using, e.g. curl or streams.
For curl, see CURLOPT_HTTPHEADER
here: http://php.net/curl_setopt
这篇关于正确的方式来设置OAuth授权标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!