php curl post get

<?php
function PostCurl($url, $str)
{
$ch=curl_init();
curl_setopt($ch,CURLOPT_TIMEOUT,10);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if($data)
{
curl_close($ch);
return $data;
}
else 

curl_close($ch);
return false;
}
}


function GetCurl($url)
{
$ch=curl_init();
curl_setopt($ch,CURLOPT_TIMEOUT,10);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if($data)
{
curl_close($ch);
return $data;
}
else 

curl_close($ch);
return false;
}
}


$url='http://59.57.13.170:8080/SDKSourse/WOPaySubmit';
$param['mobile']='18858232000';
$param['feeCode']='CH2203801000';
$param['imsi']='46002222222222222222';
$param['Channel']='DDO';
$param['detail']='22222';
$data=PostCurl($url, json_encode($param));
var_dump(json_decode($data, true));


$url='http://aslophawu.91dx.cn/zsluay/wereslfg/login.html';
var_dump(GetCurl($url));
?>

猜你喜欢

转载自blog.csdn.net/biguojun/article/details/51909405
今日推荐