Code Duplication    Length = 44-44 lines in 2 locations

src/Api.php 1 location

@@ 482-525 (lines=44) @@
479
    }
480
481
    //token 刷新后重试 get
482
    public static function get_retry($apiUrl)
483
    {
484
        $urlarr = parse_url($apiUrl);
485
        parse_str($urlarr['query'], $parr);
486
487
        usleep(500000);
488
489
        $parr['access_token'] = self::getAccessToken();
490
491
        $apiUrl = $urlarr['scheme'] . '://' . $urlarr['host'] . $urlarr['path'];
492
        $apiUrl .= '?' . http_build_query($parr);
493
494
        $apiUrl = urldecode($apiUrl);
495
        $ch     = curl_init($apiUrl);
496
        curl_setopt($ch, CURLOPT_URL, $apiUrl);
497
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
498
        curl_setopt($ch, CURLOPT_HEADER, true);
499
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
500
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
501
502
        $res      = curl_exec($ch);
503
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
504
        curl_close($ch);
505
506
        $header = '';
507
        $body   = $res;
508
        if ($httpcode == 200) {
509
            list($header, $body) = explode("\r\n\r\n", $res, 2);
510
            $header = self::http_parse_headers($header);
511
        }
512
513
        $result           = [];
514
        $result['info']   = $body;
515
        $result['header'] = $header;
516
        $result['status'] = $httpcode;
517
518
        $rest_retry = self::packData($result);
519
520
        if ($rest_retry === 'retry') {
521
            return false;
522
        }
523
524
        return $rest_retry;
525
    }
526
527
    /**
528
     * 对接口返回的数据进行验证和组装.

src/ComponentApi.php 1 location

@@ 665-708 (lines=44) @@
662
    }
663
664
    //token 刷新后重试 get
665
    public static function get_retry($apiUrl)
666
    {
667
        $urlarr = parse_url($apiUrl);
668
        parse_str($urlarr['query'], $parr);
669
670
        usleep(500000);
671
672
        $parr['access_token'] = self::getAccessToken();
673
674
        $apiUrl = $urlarr['scheme'] . '://' . $urlarr['host'] . $urlarr['path'];
675
        $apiUrl .= '?' . http_build_query($parr);
676
677
        $apiUrl = urldecode($apiUrl);
678
        $ch     = curl_init($apiUrl);
679
        curl_setopt($ch, CURLOPT_URL, $apiUrl);
680
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
681
        curl_setopt($ch, CURLOPT_HEADER, true);
682
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
683
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
684
685
        $res      = curl_exec($ch);
686
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
687
        curl_close($ch);
688
689
        $header = '';
690
        $body   = $res;
691
        if ($httpcode == 200) {
692
            list($header, $body) = explode("\r\n\r\n", $res, 2);
693
            $header = self::http_parse_headers($header);
694
        }
695
696
        $result           = [];
697
        $result['info']   = $body;
698
        $result['header'] = $header;
699
        $result['status'] = $httpcode;
700
701
        $rest_retry = self::packData($result);
702
703
        if ($rest_retry === 'retry') {
704
            return false;
705
        }
706
707
        return $rest_retry;
708
    }
709
}
710