PHP 实现oppo小游戏授权

由小游戏端发起授权,拿到oppo的授权token,其实就是相当于微信授权的code

    private function auth($oppo_token){
        $Settings = config('app_config');
        $msectimes = floor(microtime(true)*1000);
        $set['pkgName'] = $Settings['pkgName'];
        $set['appKey'] = $Settings['appKey'];
        $set['appSecret'] = $Settings['appSecret'];
        $set['token'] = $oppo_token;
        $set['timeStamp'] = $msectimes;
        ksort($set);
        $sign = md5(http_build_query($set));
        $sign = strtoupper($sign);
        $url = "https://play.open.oppomobile.com/instant-game-open/userInfo?pkgName={$Settings['pkgName']}&timeStamp=$msectimes&token=$oppo_token&sign=$sign";
        $header = array("Content-type: application/json;charset='utf-8'", "Accept: application/json");
        $curl_get = curl_get($url, $header);
        Log::info('授权信息:'.$curl_get);
        return json_decode($curl_get, true);
    }

返回数据中
errorcode=200就是正常返回

你可能感兴趣的:(PHP 实现oppo小游戏授权)