| | |
| | | $retData = array(); |
| | | $sysKey = $systemId[substr($param["id"],0,7)]; |
| | | if ($sysKey == null){ |
| | | $retData["regMsg"] = "e00001"; |
| | | $retData["rspCode"] = "e00001"; |
| | | } else { |
| | | if (checkSign($param,$sysKey)){ |
| | | $retData["regMsg"] = "e00000"; |
| | | $retData["regData"] = json_decode($param["data"],true); |
| | | $retData["rspCode"] = "e00000"; |
| | | |
| | | $retData["repData"] = json_decode($param["data"],true); |
| | | } else { |
| | | $retData["regMsg"] = "e00002"; |
| | | $retData["rspCode"] = "e00002"; |
| | | } |
| | | } |
| | | return $retData; |
| | |
| | | foreach ($data as $key => $value) |
| | | { |
| | | if ($key != "sign") { |
| | | $str = $str.$key."=".str_replace("\\", "", $value)."&"; |
| | | $str = $str.$key."=".$value."&"; |
| | | } |
| | | } |
| | | return $data["sign"] == md5($str."key=".$sysKey); |
| | |
| | | return $str; |
| | | } |
| | | |
| | | /** |
| | | * 生成openId |
| | | * @param $appId |
| | | * @return openId |
| | | */ |
| | | function getOpenId($appId) { |
| | | return $appId.date("Ymd").getRandomNumber(9); |
| | | } |
| | | |
| | | /** |
| | | *封闭curl的调用接口,get的请求方式。 |
| | | */ |
| | | function doCurlGetRequest($url,$data,$timeout = 5){ |
| | | if($url == "" || $timeout <= 0){ |
| | | return false; |
| | | } |
| | | $url = $url.'?'.http_build_query($data); |
| | | $con = curl_init((string)$url); |
| | | curl_setopt($con, CURLOPT_HEADER, false); |
| | | curl_setopt($con, CURLOPT_RETURNTRANSFER,true); |
| | | curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout); |
| | | |
| | | return curl_exec($con); |
| | | } |
| | | |
| | | /** |
| | | ** @desc 封装 curl 的调用接口,post的请求方式 |
| | | **/ |
| | | function doCurlPostRequest($url,$requestString,$timeout = 5){ |
| | | if($url == '' || $requestString == '' || $timeout <=0){ |
| | | return false; |
| | | } |
| | | $con = curl_init((string)$url); |
| | | curl_setopt($con, CURLOPT_HEADER, false); |
| | | curl_setopt($con, CURLOPT_POSTFIELDS, $requestString); |
| | | curl_setopt($con, CURLOPT_POST,true); |
| | | curl_setopt($con, CURLOPT_RETURNTRANSFER,true); |
| | | curl_setopt($con, CURLOPT_TIMEOUT,(int)$timeout); |
| | | $data = curl_exec($con); |
| | | if (curl_errno($url)) { |
| | | return curl_error($url); |
| | | } else { |
| | | curl_close($url); |
| | | return $data; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 指定key删除数组中指定的元素 |
| | | * @param unknown $data |
| | | * @param unknown $key |
| | | * @return unknown |
| | | */ |
| | | function array_remove($data, $key){ |
| | | if(!array_key_exists($key, $data)){ |
| | | return $data; |
| | | } |
| | | $keys = array_keys($data); |
| | | $index = array_search($key, $keys); |
| | | if($index !== FALSE){ |
| | | array_splice($data, $index, 1); |
| | | } |
| | | return $data; |
| | | } |
| | | function send_post($url, $post_data) { |
| | | $postdata = http_build_query($post_data); |
| | | $options = array( |
| | | 'http' => array( |
| | | 'method' => 'POST', |
| | | 'header' => 'Content-type:application/x-www-form-urlencoded', |
| | | 'content' => $postdata, |
| | | 'timeout' => 15 * 60 |
| | | ) |
| | | ); |
| | | $context = stream_context_create($options); |
| | | $result = file_get_contents($url, false, $context); |
| | | |
| | | return $result; |
| | | } |