基于PHP的聚合数据免费短信接口调用示例
- 格式:doc
- 大小:80.05 KB
- 文档页数:2
基于PHP的聚合数据天气预报api调用示例本代码示例是基于PHP的聚合数据天气预报api服务请求的代码样例,使用前你需要:①:通过/docs/api/id/39 申请一个天气预报API的appkey样例代码包含了获取支持城市列表、根据城市获取天气预报、根据IP地址请求天气预报、根据GPS坐标请求天气、城市3小时天气预报的实现。
示例代码主要是解析一些常用字段,如需要完整或其他未包含的字段,可以自行参考官方的接口,进行修改。
首先:引入封装好的天气调用类header('Content-type:text/html;charset=utf-8');include'class.juhe.weather.php'; //引入天气请求类//接口基本信息配置$appkey= '**********'; //您申请的天气查询appkey$weather= new weather($appkey);一、获取支持的城市列表由于支持的城市列表基本不会这么变化,大家可以获取到列表后内置到自己的应用中,就不用每次都去请求API。
$citysResult= $weather->getCitys();if($citysResult['error_code'] == 0){ //以下可根据实际业务需求,自行改写/////////////////////////////////////////////////////////////////// ///$citys= $citysResult['result'];foreach($citys as$ckey=>$c){echo"ID:".$c['id'].",省份:".$c['province'].",城市:".$c['city']. ",区域:".$c['district']."<br>";}}else{ //以下可根据实际业务需求,自行改写/////////////////////////////////////////////////////////////////// ///echo$citysResult['error_code'].":".$citysResult['reason'];}二、根据城市/ID获取天气预报通过城市的名称或城市的ID来获取天气预报,城市id就是获取城市支持列表中返回的字段ID$cityWeatherResult= $weather->getWeather('苏州');if($cityWeatherResult['error_code'] == 0){ //以下可根据实际业务需求,自行改写/////////////////////////////////////////////////////////////////// ///$data= $cityWeatherResult['result'];echo"=======当前天气实况=======<br>";echo"温度:".$data['sk']['temp']." ";echo"风向:".$data['sk']['wind_direction']." (".$data['sk']['win d_strength'].")";echo"湿度:".$data['sk']['humidity']." ";echo"<br><br>";echo"=======未来几天天气预报=======<br>";foreach($data['future'] as$wkey=>$f){echo"日期:".$f['date']." ".$f['week']." ".$f['weather']." ".$f ['temperature']."<br>";}echo"<br><br>";echo"=======相关天气指数=======<br>";echo"穿衣指数:".$data['today']['dressing_index']." , ".$data['today ']['dressing_advice']."<br>";echo"紫外线强度:".$data['today']['uv_index']."<br>";echo"舒适指数:".$data['today']['comfort_index']."<br>";echo"洗车指数:".$data['today']['wash_index'];echo"<br><br>";}else{echo$cityWeatherResult['error_code'].":".$cityWeatherResult['reason '];}三、根据用户的IP地址请求对应的天气预报通过用户的IP地址获取用户所在地的天气预报,由于IP地址解析可能会有误差,所以有时定位到的城市不一定是用户实际的所在地。
php手机短信验证代码(共9篇)篇一:短信验证码PHP代码篇二:用维泰SDK实现发送短信验证码php源码phprequire "httprequest.php";/*' 该示范程序通过:88/ 发送短信''返回值:'返回值大于0表示成功,小于0表示失败。
如果失败,返回信息还包括失败原因的文字描述。
'说明:'返回成功仅表示服务器已经成功接收客户提交的任务,并不表示对方已经收到短信。
'因移动公司对短信内容审核严格,如测试未收到,请及时联系客服'请不要发送"测试","你好","abc"等无意义的内容*/function smsend($strMobile,$strText){//发送短信的服务器地址$strServerURL = ":88/cgi/sendsmsbatch.asp";// 短信账号:免费申请,如有问题请联系QQ732055019// :88/mis/user_reg_form.asp?interest=sms.api $strUser= "username";// 验证密码: 初始密码由平台通过短信发送, 用户可登录平台自己修改$strPass= "userpass";if($strUser==""){echo ("短信帐号没有设定!");return;}if($strPass==""){echo ("短信验证密码没有设定!");return;}if($strMobile==""){echo ("短信接收号码无效!");return;}if($strText=="undefined|| $strText==""){echo ("短信内容不能为空!");return;}if(strlen($strText)69){echo ("短信内容不能超过69个字");return;}//准备表单:使用urlencode对参数进行编码,字符集gb2312 $strForm = "User=. urlencode($strUser);$strForm .= "&Pass=. urlencode($strPass);$strForm .= "&Mobile=. urlencode($strMobile);$strForm .= "&Text=. urlencode($strText);$h= new HttpRequest();$s= $h-request("GET",$strServerURL."?".$strFor m,"");if (strpos($s,"SUCCESS")===false){//出现错误echo ("短信通知发送失败!br.$s);}else {//发送成功echo("短信通知发送成功!");}}htmlheadtitle发送短信通知/titlemeta http-equiv="Content-Typecontent="text/html; charset=gb2312"/headbodybrdiv class="title1"发送短信通知/divdiv class="content1"$strMobile="132****9999";//接收短信的手机号码 $strText="Test SMS";//短信内容(不要超过69个字) smsend($strMobile,$strText);/div/body/htmlphp //httprequest.phpclass HttpRequest{var $_host;var $_uri;var $_port;var $_response;function parseURL($url){$req = $url;$pos = strpos($req, '://');$this-_protocol = strtolower(substr($req, 0, $pos));$req = substr($req, $pos+3);$pos = strpos($req, '/');if($pos === false)$pos = strlen($req);$host = substr($req, 0, $pos);if(strpos($host, ':') === false){$this-_host = $host;$this-_port = ($this-_protocol == 'https') ? 443 : 80;}else{list($this-_host, $this-_port) = explode(':', $host);}$this-_uri = substr($req, $pos);if($this-_uri == '')$this-_uri = '/';}function request($method , $url, $sPostData){$this-parseURL($url);$fp = pfsockopen( $this-_host, $this-_port, &$errno, &$errstr, 120); if( !$fp ) {echo "$errstr ($errno)br\n";return "";}if( strtoupper($method) == "GET"){fputs( $fp, "GET ".$this-_uri.HTTP/1.0\r\n"); }else if( strtoupper($method) == "POST) {fputs( $fp, "POST ".$this-_uri.HTTP/1.0\r\n"); }fputs( $fp, "Accept: */*\n");fputs( $fp, "Host: ".$this-_host."\r\n");fputs( $fp, "Connection: Close\r\n");if( strtoupper($method) == "POST) {$strlength = strlen( $data);fputs( $fp, "Content-type:application/x-www-form-urlencoded\r\n); fputs( $fp, "Content-length: ".$strlength."\r\n");fputs($fp, "\r\n");fputs( $fp, $data."\r\n");}else{fputs($fp, "\r\n");}$this-_response = "";while( !feof( $fp ) ) {$this-_response .= fgets( $fp, 4096);}fclose( $fp);$s = $this-getResponseBody();return $s;}function getResponse(){return $this-_response;}function getResponseBody(){$sKey = "\r\n\r\n";$pos = strpos($this-_response,$sKey);if($pos===false) return "";$str= substr($this-_response,$pos + 4);return $str;}}篇三:用免费短信验证码SDK实现手机注册验证功能用免费短信验证码SDK实现手机注册验证功能第一步获取短信SDK请到Mob官网下载最新版本的SDK,下载回来后解压,可以看到下面的文件结构:其中SMS_SDK.framework 为依赖库文件SMS_SDKDemo 为示例demo ,其中保存了短信SDK的演示项目代码。
C#短信验证api调用代码实例代码描述:基于C#的短信验证api调用代码实例代码平台:聚合数据using System;using System.Collections.Generic;using System.Linq;using System.Text;using ;using System.IO;using ;using System.Diagnostics;using System.Web;//----------------------------------// 短信API服务调用示例代码-聚合数据// 在线接口文档:/docs/54// 代码中JsonObject类下载地址:/download/gcm32060 21155665/7458439//----------------------------------namespace ConsoleAPI{class Program{static void Main(string[] args){string appkey = "*******************"; //配置您申请的appkey//1.屏蔽词检查测string url1 = "/sms/black";var parameters1 = new Dictionary<string, string>();parameters1.Add("word", ""); //需要检测的短信内容,需要UTF8 U RLENCODEparameters1.Add("key", appkey);//你申请的keystring result1 = sendPost(url1, parameters1, "get");JsonObject newObj1 = new JsonObject(result1);String errorCode1 = newObj1["error_code"].Value;if(errorCode1 == "0"){Debug.WriteLine("成功");Debug.WriteLine(newObj1);}else{//Debug.WriteLine("失败");Debug.WriteLine(newObj1["error_code"].Value+":"+newObj1 ["reason"].Value);}//2.发送短信string url2 = "/sms/send";var parameters2 = new Dictionary<string, string>();parameters2.Add("mobile", ""); //接收短信的手机号码parameters2.Add("tpl_id", ""); //短信模板ID,请参考个人中心短信模板设置parameters2.Add("tpl_value", ""); //变量名和变量值对。
一、介绍在进行接口开发过程中,经常会遇到需要获取接口请求参数的情况。
而在PHP中,我们可以通过多种方法来获取接口请求参数。
本文将介绍几种常见的方法,帮助读者更好地理解和应用PHP中获取接口请求参数的技巧。
二、使用$_GET和$_POST方法获取参数1. $_GET和$_POST是PHP中最常用的获取接口请求参数的方法。
$_GET用于获取通过URL传递的参数,而$_POST用于获取通过POST请求传递的参数。
2. 使用$_GET获取参数的示例代码如下:```php$id = $_GET['id'];$name = $_GET['name'];```3. 使用$_POST获取参数的示例代码如下:```php$username = $_POST['username'];$password = $_POST['password'];三、使用$_REQUEST方法获取参数1. $_REQUEST是一个包含了$_GET、$_POST和$_COOKIE的数组。
它可以获取通过URL、POST请求以及Cookie传递的参数。
2. 使用$_REQUEST获取参数的示例代码如下:```php$id = $_REQUEST['id'];$name = $_REQUEST['name'];```四、使用$_SERVER方法获取参数1. $_SERVER是PHP中的一个超全局数组,它包含了诸如头信息、路径以及脚本位置等信息。
我们可以使用$_SERVER['QUERY_STRING']来获取接口请求中的查询字符串参数。
2. 使用$_SERVER获取参数的示例代码如下:```php$queryString = $_SERVER['QUERY_STRING'];```五、使用file_get_contents方法获取参数1. 在某些情况下,接口请求参数可能以JSON格式传递,我们可以使用file_get_contents方法来获取接口请求的原始数据,然后将其解析为数组或对象。
使用PHP的短信平台代码<?PHP$flag = 0;//要post的数据$argv = array('sn'=>'SDK-BBX-010-XXXXX','pwd'=>'XXXXXX','mobile'=>'134338XXXXX', //测试的手机号'content'=>'你好吗,测试短信');//构造要post的字符串foreach ($argv as $key=>$value) {if ($flag!=0) {$params .= "&";$flag = 1;}$params.= $key."="; $params.= urlencode($value);$flag = 1;}$length = strlen($params);//创建socket连接$fp = fsockopen("",80,$errno,$errstr,10) orexit($errstr."--->".$errno);//构造post请求的头$header = "POST /z_send.aspx HTTP/1.1\r\n";$header .= "Host:\r\n";$header .= "Referer:/mobile/sendpost.php\r\n";$header .= "Content-Type: application/x-www-form-urlencoded\r\n";$header .= "Content-Length: ".$length."\r\n";$header .= "Connection: Close\r\n\r\n";//添加post的字符串$header .= $params."\r\n";//发送post的数据fputs($fp,$header);$inheader = 1;while (!feof($fp)) {$line = fgets($fp,1024); //去除请求包的头只显示页面的返回数据if ($inheader&& ($line == "\n" || $line == "\r\n")) {$inheader = 0;}if ($inheader == 0) {// echo $line;}}if($line==1){echo '短信发送成功请查收返回值'.$line ;}else{echo '短信发送失败,请根据返回值查看相关错误问题返回值'.$line ;}fclose($fp);。
基于php的数字阅读信息接口调用代码实例代码描述:基于php的数字阅读信息接口调用代码实例代码平台:聚合数据<!--?php// +----------------------------------------------------------------------// | JuhePHP [ NO ZUO NO DIE ]// +----------------------------------------------------------------------// | Copyright (c) 2010-2015 All rights reserved.// +----------------------------------------------------------------------// | Author: Juhedata <info@-->// +----------------------------------------------------------------------//----------------------------------// 数字阅读信息调用示例代码-聚合数据// 在线接口文档:/docs/132//----------------------------------header('Content-type:text/html;charset=utf-8');//配置您申请的appkey$appkey= "*********************";//************1.获取排行类型接口************$url= "/rank/getRankType";$params= array("key"=> $appkey,//应用APPKEY);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************//************2.获取排行内容数据接口************$url= "/rank/getRankInfo";$params= array("key"=> $appkey,//应用APPKEY"contentType"=> "",//内容类型ID,可通过调用“获取排行类型信息接口”获取"rankType"=> "",//排行类型ID,可通过调用“获取排行类型信息接口”获取"rankTime"=> "",//排行时间类型ID,可通过调用“获取排行类型信息接口”获取"start"=> "",//获取数据的起始条数,默认为0"count"=> "",//获取数据的总条数,默认为18"copyRight"=> "",//内容书籍的版权,不传参数默认获取所有书籍,不对版权进行过滤 1、有线版权 2、无线版权 3、无转授权 4、无信息网络传播权);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************//************3.获取推荐类型************$url= "/189/read/getRecommendType"; $params= array("key"=> $appkey,//应用APPKEY(应用详细页查询)"dtype"=> "",//返回数据的格式,xml或json,默认json );$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************//************4.获取热门搜索推荐************$url= "/hotwords/hot.from";$params= array("key"=> $appkey,//您申请的appkey);$paramstring= http_build_query($params);$content= juhecurl($url,$paramstring);$result= json_decode($content,true);if($result){if($result['error_code']=='0'){print_r($result);}else{echo$result['error_code'].":".$result['reason'];}}else{echo"请求失败";}//**************************************************/*** 请求接口返回内容* @param string $url[请求的URL地址]* @param string $params[请求的参数]* @param int $ipost[是否采用POST形式]* @return string*/function juhecurl($url,$params=false,$ispost=0){$httpInfo= array();$ch= curl_init();curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData');curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );curl_setopt( $ch, CURLOPT_TIMEOUT , 60);curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);if( $ispost){curl_setopt( $ch, CURLOPT_POST , true );curl_setopt( $ch, CURLOPT_POSTFIELDS , $params);curl_setopt( $ch, CURLOPT_URL , $url);}else{if($params){curl_setopt( $ch, CURLOPT_URL , $url.'?'.$params);}else{curl_setopt( $ch, CURLOPT_URL , $url);}}$response= curl_exec( $ch);if($response=== FALSE) {//echo "cURL Error: " . curl_error($ch);return false;}$httpCode= curl_getinfo( $ch, CURLINFO_HTTP_CODE );$httpInfo= array_merge( $httpInfo, curl_getinfo( $ch) );curl_close( $ch);return$response;}。
PHP开发调⽤阿⾥云短信验证码的代码-直接可⽤1:最低要求 PHP 5.62:安装了composer3:阿⾥云composer镜像地址命令(如果设置过就不需要):composer config -g repo.packagist composer https:///composer/4:安装 SDK 核⼼库 OpenAPI : Alibaba Cloud SDK for PHP 作为依赖项:composer require alibabacloud/darabonba-openapi5:阿⾥云短信SDK安装包命令(官⽅地址:https:///api-tools/sdk/Dysmsapi):composer require alibabacloud/dysmsapi-20170525 2.0.8<?php// This file is auto-generated, don't edit it. Thanks.namespace lib;use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;use Darabonba\OpenApi\Models\Config;class aliyunSms{private static $accessKeyId = 'LTAI5t7AC3RH3333pZTDCaA3';//accessKeyIdprivate static $accessKeySecret = 'ihDUcyqNZvNYXASfLtijI33333NSk';//accessKeySecretprivate static $signName = 'xxxx技有限公司';//签名private static $templateCode = 'SMS_228533331';//模板代码/*** 使⽤AK&SK初始化账号Client* @param string $accessKeyId* @param string $accessKeySecret* @return Dysmsapi Client*/private static function createClient($accessKeyId, $accessKeySecret){$config = new Config([// 您的AccessKey ID"accessKeyId" => $accessKeyId,// 您的AccessKey Secret"accessKeySecret" => $accessKeySecret]);// 访问的域名$config->endpoint = "";return new Dysmsapi($config);}/*** @param string $phoneNumbers ⼿机号* @param string $code 验证码* @return void*/// public static function main($args)private static function main($phoneNumbers, $code){$client = self::createClient(self::$accessKeyId, self::$accessKeySecret);$sendSmsRequest = new SendSmsRequest(["templateParam" => "{\"code\":\"{$code}\"}","phoneNumbers" => "{$phoneNumbers}","signName" => self::$signName,"templateCode" => self::$templateCode]);$ali_res = $client->sendSms($sendSmsRequest);if ($ali_res->body->code == 'OK' && $ali_res->body->bizId != NULL) {return true;}switch ($ali_res->body->code) {case 'isv.BUSINESS_LIMIT_CONTROL':exception('短信发送频繁,请稍候再试');//tp的抛出错误,换成你⾃⼰的报错break;case 'isv.TEMPLATE_PARAMS_ILLEGAL':exception('短信验证码不符合变量规范');//tp的抛出错误,换成你⾃⼰的报错break;case 'isv.MOBILE_NUMBER_ILLEGAL':exception('⼿机号不正确,⽆法发送短信');//tp的抛出错误,换成你⾃⼰的报错break;}//少见的错误,记录下来//log_err($ali_res->body, '发送短信发⽣错误', 'ali_sms');//换成你的exception($ali_res->body->message);//tp的抛出错误,换成你⾃⼰的报错// 以下是阿⾥云短信正确和失败返回的数据,以作参考// 失败演⽰返回数据/* object(AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsResponseBody)#81 (6) {["bizId"] => NULL["code"] => string(24) "isv.SMS_TEMPLATE_ILLEGAL"["message"] => string(38) "模板不合法(不存在或被拉⿊)"["requestId"] => string(36) "21A90D61-2D5E-533D-BFE7-9D16F8312A0E"["_name":protected] => array(4) {["bizId"] => string(5) "BizId"["code"] => string(4) "Code"["message"] => string(7) "Message"["requestId"] => string(9) "RequestId"}["_required":protected] => array(0) {}}*/// 成功返回数据演⽰/* object(AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsResponseBody)#81 (6) {["bizId"] => string(20) "839015438514162136^0"["code"] => string(2) "OK"["message"] => string(2) "OK"["requestId"] => string(36) "EA37C2B7-E427-59F8-8B7C-06AD846A5439"["_name":protected] => array(4) {["bizId"] => string(5) "BizId"["code"] => string(4) "Code"["message"] => string(7) "Message"["requestId"] => string(9) "RequestId"}["_required":protected] => array(0) {}}*/}//发短信public static function sendSms($phoneNumbers, $code){$res = self::main($phoneNumbers, $code);return $res;}}此代码只需要修改命名空间和阿⾥云accessKeyId等相关信息,即可使⽤~exception是TP的错误异常抛出,我是做了全局的异常托管,并且在所有报错的地⽅调⽤此⽅法就能终端代码,报出错误,你只需要换成你的中断代码返回错误即可。
基于Python的聚合数据短信验证码接口调用示例本代码示例是基于Python的聚合数据短信验证码接口请求的代码样例,使用前你需要:①:通过/docs/api/id/54 申请短信API服务②:在短信模板中心,添加一个模板,并通过审核以下是完整的代码示例:#!/usr/bin/python#coding:utf-8import urllib, jsondef main():appkey ='***************'#您申请的短信服务appkeymobile ='1891351****'#短信接受者的手机号码tpl_id ='441'#申请的短信模板ID,根据实际情况修改tpl_value ='#code#=5678&#company#=JuheData'#短信模板变量,根据实际情况修改sendsms(appkey, mobile, tpl_id, tpl_value) #请求发送短信def sendsms(appkey, mobile, tpl_id, tpl_value):sendurl ='/sms/send'#短信发送的URL,无需修改params ='key=%s&mobile=%s&tpl_id=%s&tpl_value=%s'%\(appkey, mobile, tpl_id, urllib.quote(tpl_value)) #组合参数wp =urllib.urlopen(sendurl+"?"+params)content =wp.read() #获取接口返回内容result =json.loads(content)if result:error_code =result['error_code']if error_code ==0:#发送成功smsid =result['result']['sid']print"sendsms success,smsid: %s"%(smsid)else:#发送失败print"sendsms error :(%s) %s"%(error_code, result['reason '])else:#请求失败print"request sendsms error"if__name__ =='__main__':main()。
基于PHP的聚合数据免费短信接口调用示例
本代码示例是基于PHP的聚合数据短信API服务请求的代码样例,使用前你需要:
①:通过/docs/api/id/54 申请短信API服务
②:在短信模板中心,添加一个模板,并通过审核
以下是完整的代码示例:
<!--?php
/*
***聚合数据()短信API服务接口PHP请求示例源码
***DATE:2015-05-25
*/
header('content-type:text/html;charset=utf-8');
$sendUrl= '/sms/send'; //短信接口的URL
$smsConf= array(
'key' =--> '*****************', //您申请的APPKEY
'mobile'=> '1891351****', //接受短信的用户手机号码
'tpl_id'=> '111', //您申请的短信模板ID,根据实际情况修改
'tpl_value'=>'#code#=1234&#company#=聚合数据'//您设置的模板变量,根据实际情况修改
);
$content= juhecurl($sendUrl,$smsConf,1); //请求发送短信
if($content){
$result= json_decode($content,true);
$error_code= $result['error_code'];
if($error_code== 0){
//状态为0,说明短信发送成功
echo"短信发送成功,短信ID:".$result['result']['sid'];
}else{
//状态非0,说明失败
$msg= $result['reason'];
echo"短信发送失败(".$error_code."):".$msg;
}
}else{
//返回内容异常,以下可根据业务逻辑自行修改
echo"请求发送短信失败";
}
/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int $ipost [是否采用POST形式]
* @return string
*/
function juhecurl($url,$params=false,$ispost=0){
$httpInfo= array();
$ch= curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 5.
1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/5 37.22');
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 30 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 30);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
if( $ispost)
{
curl_setopt( $ch, CURLOPT_POST , true );
curl_setopt( $ch, CURLOPT_POSTFIELDS , $params);
curl_setopt( $ch, CURLOPT_URL , $url);
}
else
{
if($params){
curl_setopt( $ch, CURLOPT_URL , $url.'?'.$params);
}else{
curl_setopt( $ch, CURLOPT_URL , $url);
}
}
$response= curl_exec( $ch);
if($response=== FALSE) {
//echo "cURL Error: " . curl_error($ch);
return false;
}
$httpCode= curl_getinfo( $ch, CURLINFO_HTTP_CODE );
$httpInfo= array_merge( $httpInfo, curl_getinfo( $ch) );
curl_close( $ch);
return$response;
}。