抖音主页链接解析个人信息

 public function douyin($url)
    {
        $redirect_url = $this->get_redirect_url($url);
        $sec_user_id = str_replace(['https://www.douyin.com/user/','?previous_page=app_code_link'],['',''],$redirect_url);
        $info_url ='https://www.iesdouyin.com/web/api/v2/user/info/?sec_uid='.$sec_user_id;
        $output = file_get_contents($info_url);
        $res = json_decode($output,true);
        if (isset($res['user_info'])){
            $result = $res['user_info'];
            return [
                'nickname' =>$result['nickname'],
                'home_url' => $url,
                'platform' => 'douyin',
                'uid' => $result['uid'],
                'video_uid' => $result['unique_id'],
                'fans_total'=>$result['follower_count'],
                'avatar' => $result['avatar_medium']['url_list'][0],
                'signature' => $result['signature'],
                'sec_uid' => $sec_user_id
            ];
        }else{
            return false;
        }
    }
 /**
     *  重定向地址
     * @param $url
     * @return mixed
     */
    public function get_redirect_url($url){
        $header = get_headers($url, 1);
        if (strpos($header[0], '301') !== false || strpos($header[0], '302') !== false) {
            if(is_array($header['Location'])) {
                return $header['Location'][count($header['Location'])-1];
            }else{
                return $header['Location'];
            }
        }else {
            return $url;
        }
    }
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

现在好像这接口不能用了

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!