1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > php 获取header auth php CURL Auth请求头和响应头获取

php 获取header auth php CURL Auth请求头和响应头获取

时间:2018-10-13 10:12:17

相关推荐

php 获取header auth php CURL Auth请求头和响应头获取

$oCurl = curl_init();

// 设置请求头, 有时候需要,有时候不用,看请求网址是否有对应的要求

$header[] = "Content-type: application/x-www-form-urlencoded";

$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";

curl_setopt($oCurl, CURLOPT_URL, $sUrl);

curl_setopt($oCurl, CURLOPT_HTTPHEADER,$header);

// 返回 response_header, 该选项非常重要,如果不为 true, 只会获得响应的正文

curl_setopt($oCurl, CURLOPT_HEADER, true);

// 是否不需要响应的正文,为了节省带宽及时间,在只需要响应头的情况下可以不要正文

curl_setopt($oCurl, CURLOPT_NOBODY, true);

// 使用上面定义的 ua

curl_setopt($oCurl, CURLOPT_USERAGENT,$user_agent);

curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );

// 不用 POST 方式请求, 意思就是通过 GET 请求

curl_setopt($oCurl, CURLOPT_POST, false);

$sContent = curl_exec($oCurl);

// 获得响应结果里的:头大小

$headerSize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE);

// 根据头大小去获取头信息内容

$header = substr($sContent, 0, $headerSize);

curl_close($oCurl);

Linux下用base64命令加解密字符串

加密:

$ echo Hello World | base64

SGVsbG8gV29ybGQK

解密:

$ echo SGVsbG8gV29ybGQK | base64 -d

Hello World

原文

/tianye8123/p/5942643.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。