Php cinema box office api call code example
Php cinema box office api call code example
// + ---------------------------------------------------------------------- // ---------------------------- // Sample code of movie box office call-aggregate data // online interface documentation: http://www.juhe.cn/docs/44//---------------------------------- Header ('content-type: text/html; charset = utf-8 '); // Configure Your applied appkey $ appkey = "*********************"; // ************* 1. * $ url =" http://v.juhe.cn/boxoffice/rank "; $ Params = array (" area "=>" ", // area of the room list, CN-mainland China, US-North America, HK-Hong Kong" key "=> $ appkey, // application APPKEY (query on the application details page) "dtype" => "", // format of returned data, xml/json, default 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 "request failed ";} //************************************** * *********** // *************** 2. ticket Box Office ************ $ url =" http://v.juhe.cn/boxoffice/wp "; $ Params = array (" key "=> $ appkey, // apply APPKEY" dtype "=>" ", // The format of the returned data, in xml or json format, default 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 "request failed ";} //************************************** ************/* ** Request interface returned content * @ param string $ url [requested URL] * @ param string $ params [request parameters] * @ param int $ ipost [whether POST is used] * @ 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 ($ c H, CURLOPT_TIMEOUT, 60); curl_setopt ($ ch, success, 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 ;}
The above is the content of the php cinema line Box Office api call code instance. For more information, see PHP Chinese network (www.php1.cn )!