色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php發送post請求函數分享

復制代碼 代碼如下:
function do_post_request($url, $data, $optional_headers = null)
{
 $params = array('http' => array(
'method' => 'POST',
'content' => $data
 ));
 if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
 }
 $ctx = stream_context_create($params);
 $fp = @fopen($url, 'rb', false, $ctx);
 if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
 }
 $response = @stream_get_contents($fp);
 if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
 }
 return $response;
}


用法如下:
復制代碼 代碼如下:
//json字符串
$data = "{...}";
//轉換成數組
$data=json_decode($data,true);
$postdata = http_build_query($data);
do_post_request("http://localhost",$postdata);

php技術php發送post請求函數分享,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 通州区| 祁门县| 松阳县| 咸阳市| 利川市| 舞阳县| 六枝特区| 绵阳市| 上犹县| 涿州市| 霍林郭勒市| 封开县| 阜城县| 嘉义市| 四平市| 来安县| 东至县| 体育| 河西区| 象山县| 平邑县| 淮南市| 富顺县| 鄱阳县| 徐汇区| 嘉定区| 英吉沙县| 宁陵县| 滦南县| 澄江县| 上栗县| 辛集市| 横峰县| 通江县| 通辽市| 繁峙县| 牟定县| 六枝特区| 塘沽区| 新晃| 东宁县|