【发布时间】:2012-04-05 15:59:58
【问题描述】:
如何使用 youtube api 从 localhost Web 应用程序在 codeigniter 或 php 中上传视频?
我按照 youtube 库中的步骤如下:
api key : 'my developer key'
consumer key : 'anonymous'
consumer secret : 'anonymous'
我正在使用以下功能,我的网站网址是:http://localhost/ci-youtube/example/request_youtube
//CALL THIS METHOD FIRST BY GOING TO
//www.your_url.com/index.php/request_youtube
public function request_youtube()
{
$params['key'] = 'anonymous';
$params['secret'] = 'anonymous';
$params['algorithm'] = 'HMAC-SHA1';
$this->load->library('google_oauth', $params);
$data = $this->google_oauth->get_request_token(site_url('example/access_youtube'));
print_r($data);
$this->session->set_userdata('token_secret', $data['token_secret']);
redirect($data['redirect']);
//$this->load->view('welcome_message');
}
//This method will be redirected to automatically
//once the user approves access of your application
public function access_youtube()
{
$params['key'] = 'anonymous';
$params['secret'] = 'anonymous';
$params['algorithm'] = 'HMAC-SHA1';
$this->load->library('google_oauth', $params);
$oauth = $this->google_oauth->get_access_token(false, $this->session->userdata('token_secret'));
$this->session->set_userdata('oauth_token', $oauth['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $oauth['oauth_token_secret']);
}
但它显示错误:'Invalid Token'
有什么想法吗?
提前感谢您的快速回复。
【问题讨论】:
-
您的查询可能使用了错误的基本网址。
-
google_oauth 有错误处理吗?即:这->google_oauth->last_error ?如果是这样,请记录它并查看它给出的反馈。
-
@Philip:我得到了回复:$response = $this->_connect("{$baseurl}?scope={$auth['scope']}", $str); as 'Timestamp is too far from current time: 1332315674'
-
它并没有真正泄露多少
标签: php codeigniter youtube-api