问题描述
我在哪里可以找到的access_token
, refresh_token
我在优酷网的帐户?
Where can I find the access_token
, refresh_token
in my youku account?
我发现了如何使用外部脚本使用API来上传视频youku.com,但我需要的access_token
, refresh_token
来使用它。
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.
推荐答案
您必须授权优酷的应用程序,并使用get code获得令牌。
You need to authorize your Youku app and to use the get code to obtain a token.
- 转至<$c$c>https://openapi.youku.com/v2/oauth2/authorize?client_id={YOURCLIENTID}&response_type=$c$c&redirect_uri={YOURCALLBACKURL}$c$c>.
- 接受授权。你会被重定向到您的回调URL。要小心,它应该比在创建您的应用程序的优酷(相同的协议也行)你输入一个相同的。
-
使用GET参数code。通过做一个POST卷曲调用的使用以下参数
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;
}
在$结果将是包含的access_token JSON数组<$c$c>{\"access_token\":\"3cc08bffcd48a86a0e540f9ed1be42f4\",\"expires_in\":\"2592000\",\"refresh_token\":\"f8d78ce2005c9d1e0b62cd29f61ba3f9\",\"token_type\":\"bearer\"}$c$c>
The $result will be a json array containing the access_token {"access_token":"3cc08bffcd48a86a0e540f9ed1be42f4","expires_in":"2592000","refresh_token":"f8d78ce2005c9d1e0b62cd29f61ba3f9","token_type":"bearer"}
在这里更多的Infor:
More infor here : http://open.youku.com/docs/docs?id=101
这篇关于如何获得优酷的access_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!