static function getUserInfo($access_token) { $curl = new Curl(); $url = SSO_USER_INFO_URL . "&access_token=" . $access_token; $res = $curl->get($url); $body = json_decode($res['body'], 1); $user_info = null; if ($body['error'] == 0) { $user_info = $body['result']; //self::_debug($user_info); } return $user_info; }
static function api($action, $query, $use_ip = false) { $curl = new Curl(); try { $url = self::get_url($action, $query, $use_ip); self::_debug($url); $response = $curl->get($url, array(CURLOPT_REFERER => PASSPORT_HOST)); //self::_debug($response); } catch (Exception $e) { self::_error($e->getMessage()); _throw("call passport api error"); } return self::handle_response($response); }
static function convert_gps($latx, $lngy) { //PtApp::$setting['qq_map']['key_service'] $key = Model_Setting::get("qq_map_key_service1"); if (!$key) { Model_Setting::add("qq_map_key_service1", "I6OBZ-EFNHR-JAZWY-WHLXW-O3TOH-EIFLA", "QQ地图 SERVICE KEY"); Model_Setting::add("qq_map_key_js", "66DBZ-IG7WJ-G2CFQ-KVS4Z-PBQA5-WQFLR", "QQ地图 JS KEY"); } $url = "http://apis.map.qq.com/ws/coord/v1/translate"; $data = array("locations" => $latx . "," . $lngy, "type" => 1, "key" => $key); $curl = new Curl(); $url = $url . "?" . http_build_query($data); $res = $curl->get($url); $body = json_decode($res['body']); if ($body->status > 0) { throw new Exception($body->message); } return $body->locations[0]; }
/** * @param $mobile * @param $data * @return mixed * @throws AppException * @throws Exception */ static function send_by_tpl($mobile, $data) { if (!self::$apikey) { _throw("YUNPIN APIKEY IS NULL"); } $curl = new Curl(); try { $url = "http://yunpian.com/v1/sms/tpl_send.json"; $data['apikey'] = self::$apikey; $data['mobile'] = $mobile; $res = $curl->post($url, $data); $body = json_decode($res['body']); if ($body->code > 0) { _throw($body->msg . " " . $body->detail); } return $body; } catch (Exception $e) { throw new Exception($e->getMessage()); } }
function http_request($method, $url, $options) { $curl = new Curl(); $_options = array(); $data = ""; if (isset($options["data"])) { if (is_array($options["data"]) || is_object($options["data"])) { if (!empty($options['setting']["post_json"])) { $data = json_encode($options["data"]); } else { $data = http_build_query($options['data']); } } else { $data = $options["data"]; } } if (!empty($options['setting']["debug"])) { $_options[CURLOPT_VERBOSE] = 1; } if (!empty($options['setting']["cookie_file"])) { $_options[CURLOPT_COOKIEFILE] = $options['setting']["cookie_file"]; } if (!empty($options['setting']["local_proxy"])) { $_options[CURLOPT_HTTPPROXYTUNNEL] = 1; if ($options['setting']["local_proxy"] == 1) { $_options[CURLOPT_PROXY] = "127.0.0.1:80"; } else { $_options[CURLOPT_PROXY] = $options['setting']["local_proxy"]; } } $url = $this->__parse_url_action($url); $res = $curl->request(strtoupper($method), $url, $data, $_options); if (empty($options['setting']["debug"])) { if (!empty($options['setting']["print_response"])) { echo "\nHTTP Response\n"; print_r($res); echo "\n"; } else { if (!empty($options['setting']["print_response_header"])) { echo "\nHTTP Response Header:\n"; echo $res['header']; echo "\n"; } if (!empty($options['setting']["print_response_cookie"])) { echo "\nHTTP Response Cookie: in ==> " . $res['cookie_file'] . "\n"; print_r($res['cookie']); echo "\n"; } if (!empty($options['setting']["print_response_info"])) { echo "\nHTTP Response Info: in ==> " . $res['cookie_file'] . "\n"; print_r($res['info']); echo "\n"; } } } return $res['body']; }