-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Netflix API Library
Category:Contributions::Libraries::Netflix API Category:Libraries::Netflix API Category:Library::Netflix API
Please checkout the github repository for the latest version
https://github.com/jimdoescode/CodeIgniter-Netflix-API-Library
This documentation expects that you have a reasonable understanding of OAuth and have gotten and API Key and API Secret from Netflix.
This library will let you interact with the Netflix API and perform actions such as managing a users queue or search for movie titles. All responses from the API are raw XML and will need to be parsed by you.
You can get an oauth access token for the API by using controller methods similar to these:
public function request_netflix()
{
$params['key'] = 'NETFLIX CONSUMER KEY';
$params['secret'] = 'NETFLIX CONSUMER SECRET';
$this->load->library('netflix', $params);
$data = $this->netflix->get_request_token(site_url("welcome/access_netflix"));
$this->session->set_userdata('token_secret', $data['token_secret']);
redirect($data['redirect']);
}
public function access_netflix()
{
$params['key'] = 'bgpnp9esm2j5tr225dmm23a3';
$params['secret'] = 'n6AUqxtZDf';
$this->load->library('netflix', $params);
$oauth = $this->netflix->get_access_token($this->session->userdata('token_secret'));
$this->_store_in_db($oauth['oauth_token']);
$this->_store_in_db($oauth['oauth_token_secret']);
}
Once you have an access token and token secret you can now make authenticated requests on the users behalf. These tokens do not expire so you should only need to perform this action once per user.
After you have a token and token secret you can now pass those to the library when it is loaded like this.
$params['key'] = 'NETFLIX CONSUMER KEY';
$params['secret'] = 'NETFLIX CONSUMER SECRET';
$params['access'] = array('oauth_token'=>urlencode('ACCESS TOKEN'),
'oauth_token_secret'=>urlencode('ACCESS TOKEN SECRET'));
$this->load->library('netflix', $params);
Now that the library is loaded with the correct credentials you can call any of the methods below.
$this->netflix->search_title($title, array $params = array());
$this->netflix->search_title_autocomplete($title);
$this->netflix->all_titles(array $params = array());
$this->netflix->get_title_details($id, $type, $season = false);
$this->netflix->get_title_similars($id, $type, $season = false, array $params = array());
$this->netflix->search_people($name, array $params = array());
$this->netflix->get_person_details($id);
$this->netflix->get_user($id = 'current');
$this->netflix->get_user_feeds($id, array $params = array());
$this->netflix->get_user_title_states($id, array $params = array());
$this->netflix->get_queues($id, $type = '', array $params = array());
$this->netflix->get_queue_state($id, $type, $state, $entry = '', array $params = array());
$this->netflix->remove_queue_entry($id, $type, $state, $entry);
$this->netflix->add_queue_entry($id, $type, $title_ref, $etag, $position = '1');
$this->netflix->get_rental_history($id, $instant_watched = false, array $params = array());
$this->netflix->get_title_rating($id, $title_refs, $predicted = false);
$this->netflix->set_title_rating($id, $title_ref, $rating, $ratingId = false);
$this->netflix->get_recommendations($id, array $params = array());
For further documentation or if you have any questions you can reach me at my blog
http://jimdoescode.blogspot.com/2011/10/probably-bad-timing-but-here-is-netflix.html
This library is kind of tough to work with since it requires many ID's that you must retrieve from other API calls. Make sure you read the Netflix API docs for more information
developer.netflix.com/docs/REST_API_Reference
Have fun.