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代码获取token.You need to authorize your Youku app and to use the get code to obtain a token.转到https://openapi.youku.com/v2/oauth2/authorize?client_id={YOURCLIENTID}&response_type=code&redirect_uri={YOURCALLBACKURL}.接受授权.您将被重定向到您的回调 URL.请注意,它应该与您在创建优酷应用程序时输入的相同(同样的协议).通过对 执行 POST CURL 调用,使用 get 参数代码获取您的访问令牌https://openapi.youku.com/v2/oauth2/token 带有以下参数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;}$result 将是一个包含 access_token 的 json 数组 {"access_token":"3cc08bffcd48a86a0e540f9ed1be42f4","expires_in":"2592000","re​​fresh_token":"f8d78ce232009"f8d78ce20009"f8d78ce2009"6cbfcd48a86a0e540f9ed1be42f4"The $result will be a json array containing the access_token {"access_token":"3cc08bffcd48a86a0e540f9ed1be42f4","expires_in":"2592000","refresh_token":"f8d78ce2005c9d1e0b62cd29f61ba3f9","token_type":"bearer"}更多信息在这里:http://open.youku.com/docs/docs?id=101 这篇关于如何获取优酷access_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 14:23
查看更多