国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
php 如何發(fā)送http請(qǐng)求和實(shí)現(xiàn)https接口

1。輸入接口:

https://CRMC URL/ spservice/downring.do? sid =1234 & sidpwd =123456& randomsessionkey =123420031212121212123456& modulecode=z1000XXX&opertype=1&tonecode=1234123412& issendsms =0& backurl=

2。如何發(fā)送http請(qǐng)求,最好有例子,謝謝!

 

PHP的文件操作函數(shù)幾乎都能用來發(fā)送http請(qǐng)求:

$html = file_get_contents('http://ww.google.com');
var_dump
($html);

有些網(wǎng)站會(huì)對(duì)請(qǐng)求頭信息進(jìn)行檢測(cè),這時(shí)候就需要用到curl了(php.ini中要啟用curl擴(kuò)展),貼一個(gè)我一直用的函數(shù):

function fetch_page($site,$url,$params=false)
{
    $ch
= curl_init();
    $cookieFile
= $site . '_cookiejar.txt';
    curl_setopt
($ch, CURLOPT_COOKIEJAR, $cookieFile);
    curl_setopt
($ch, CURLOPT_COOKIEFILE,$cookieFile);
    curl_setopt
($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt
($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt
($ch,   CURLOPT_SSL_VERIFYPEER,   FALSE);
    curl_setopt
($ch, CURLOPT_HTTPGET, true);
    curl_setopt
($ch, CURLOPT_TIMEOUT, 4);
   
if($params)
        curl_setopt
($ch, CURLOPT_POSTFIELDS, $params);
    curl_setopt
($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
    curl_setopt
($ch, CURLOPT_URL,$url);

    $result
= curl_exec($ch);
   
//file_put_contents('jobs.html',$result);
   
return $result;
}

調(diào)用示例:

$html = fetch_page('google','http://googlel.com','key=value');
var_dump
($html);

如果請(qǐng)求類型是https,則只能用curl了,前者會(huì)報(bào)(至少默認(rèn)情況下):

PHP Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?

如果你說的實(shí)現(xiàn)https接口指的是讓別人可以用https訪問你,那么就需要用openssl生成公私鑰,然后編譯apache使支持mod_ssl,然后再配置httpd-ssl.conf文件,這些讓系統(tǒng)管理員來做吧。。

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
php獲取通過http協(xié)議post提交過來xml數(shù)據(jù)及解析xml
php抓取https的內(nèi)容的代碼
關(guān)于php 接口問題(php接口主要也就是運(yùn)用curl,curl函數(shù))
php執(zhí)行https接口get的方式
PHP curl
訪問https資源
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服