[PHP] 统一的API接口调用【O2O】 →→→→→进入此内容的聊天室

来自 , 2019-07-18, 写在 PHP, 查看 104 次.
URL http://www.code666.cn/view/75df6360
  1. /**
  2.      * 统一API接口调用
  3.      *
  4.      * @param array $req_params 请求的参数数组
  5.      * @param string $url_path 调用的接口PHP路径,不保含主机地址
  6.      * @return array
  7.      */
  8.     static public function api($req_params, $url_path)
  9.     {
  10.         $req = array('sid' => self::$api_cfg['sid'], 'appkey' => self::$api_cfg['appkey'], 'timestamp' => time());
  11.         $appSecret = self::$api_cfg['appsecret'];
  12.         $pre_dir = self::$api_cfg['predir'];
  13.  
  14.         $req = array_merge($req, $req_params);
  15.         self::makeSign($req, $appSecret);
  16.         Log::LOG('wdt_api', "req param:" . print_r($req, true));
  17.         $service_url = "http://" . self::$api_cfg['host'] . $pre_dir . $url_path . '?' . http_build_query($req);
  18.         $response = file_get_contents($service_url);
  19.         Log::LOG('wdt_api', "req url:" . $service_url);
  20.         Log::LOG('wdt_api', $response);
  21.         if ($response === false) return false;
  22.         $json = json_decode($response, true);
  23.         Log::LOG('wdt_api', "response:" . print_r($json, true));
  24.         return $json;
  25.     }

回复 "统一的API接口调用【O2O】"

这儿你可以回复上面这条便签

captcha