自己在用的一个api转接程序,可以将别人的api转接成自己的api,非常好用。
<?phpfunction curlget($url,$method='get',$data=null){$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000);curl_setopt($ch, CURLOPT_TIMEOUT, 500);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);if($method=='post'){curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);}$result = curl_exec($ch);curl_close($ch);if(!$result){//curl 出现错误return false;}return $result;}$postdata = $_REQUEST;$res = @curlget($url,"post",$postdata);echo($res);<?php function curlget($url,$method='get',$data=null){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000); curl_setopt($ch, CURLOPT_TIMEOUT, 500); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($method=='post'){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); } $result = curl_exec($ch); curl_close($ch); if(!$result){ //curl 出现错误 return false; } return $result; } $postdata = $_REQUEST; $res = @curlget($url,"post",$postdata); echo($res);<?php function curlget($url,$method='get',$data=null){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000); curl_setopt($ch, CURLOPT_TIMEOUT, 500); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($method=='post'){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); } $result = curl_exec($ch); curl_close($ch); if(!$result){ //curl 出现错误 return false; } return $result; } $postdata = $_REQUEST; $res = @curlget($url,"post",$postdata); echo($res);
© 版权声明
THE END
- 最新
- 最热
只看作者