How to get youku access_token

a 夏天 提交于 2019-12-25 07:27:31

问题


Where can I find the access_token, refresh_token in my youku account?

I found out how to upload video to youku.com using external script with the use of a API, but I need access_token, refresh_token to use it.


回答1:


You need to authorize your Youku app and to use the get code to obtain a token.

  1. Go to https://openapi.youku.com/v2/oauth2/authorize?client_id={YOURCLIENTID}&response_type=code&redirect_uri={YOURCALLBACKURL}.
  2. Accept the authorization. You will be redirected to your callback URL. Be careful, it should be the same than the one you entered while creating your Youku application (same protocol too).
  3. Use the get parameter code to get your access token by doing a POST CURL call to https://openapi.youku.com/v2/oauth2/token with the following parameters

    if(isset($_GET['code']))
    {
        $url    = "https://openapi.youku.com/v2/oauth2/token";
        $params = array(
            "client_id"     => $client_id,
            "client_secret" => $client_secret,
            "grant_type"    => 'authorization_code',
            "code"      => $_GET['code'],
            "redirect_uri"  => $callback_url
        );
    
        $str_params = http_build_query($params);
        $ch = curl_init();
    
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $str_params);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
    
        echo $result;
    }
    

The $result will be a json array containing the access_token {"access_token":"3cc08bffcd48a86a0e540f9ed1be42f4","expires_in":"2592000","refresh_token":"f8d78ce2005c9d1e0b62cd29f61ba3f9","token_type":"bearer"}

More infor here : http://open.youku.com/docs/docs?id=101




回答2:


You can find the Youku api here: http://open.youku.com/docs/tech_doc.html It is in Chinese, so I suggest you open this link using google chrome, then right click the page (after it is finished loading) and press 'Translate to English'

Hope this helps



来源:https://stackoverflow.com/questions/23415774/how-to-get-youku-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!