码迷,mamicode.com
首页 > Windows程序 > 详细

获取API返回值

时间:2015-04-27 13:10:30      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

//$return=getApiResult($url);
//    if ($return==200){
//        //.....
//    }
function getApiResult($url){
    if(function_exists(‘file_get_contents‘)){
        $file_contents = file_get_contents($url);
    }
    else{
        $ch = curl_init();
        $timeout = 5;
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $file_contents = curl_exec($ch);
        curl_close($ch);

    }
    return $file_contents;
} 

 

获取API返回值

标签:

原文地址:http://www.cnblogs.com/mssql8/p/4459791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!