4. Youtube API : Request to Youtube Authentication

Posted: 07/11/2013 in Youtube API
Tags: , ,

1. Request to Youtube using API

public function request_youtube()
 {
 $params['key'] = xxxxxxxxxxxx.apps.googleusercontent.com';
 $params['secret'] = 'xxxxxxxxxxxx';
 $params['algorithm'] = 'HMAC-SHA1';
$this->load->library('google_oauth', $params);
 $data = $this->google_oauth->get_request_token(base_url().'index.php/example/access_youtube');
 $this->session->set_userdata('token_secret', $data['token_secret']);
 redirect($data['redirect']);
 }

2. Access

public function access_youtube()
 {
 $params['key'] = xxxxxxxxxxxx.apps.googleusercontent.com';
 $params['secret'] = 'xxxxxxxxxxxx';
 $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']);
redirect(base_url().'index.php/controller/method');
 }

Refereed By : Google API’s

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s