#TiYouTubeAPI#
YouTube library for making API requests from Appcelerator Titanium apps easier.
- Put youtube.js and googleAuth.js in your /app/lib/ folder.
- Signup to use the Youtube API here: Google Developers Console
- Create a new project
- Enable 'YouTube Data API v3' (APIs & auth >> APIs >> YouTube Data API v3)
- Create a new OAuth Client ID (APIs & auth >> Credentials >> Create new Client ID)
- Open /app/config.json and add your credential information. Example:
{
"global": {
"googleAuth": {
"clientId": "1059383751733-a1ne37if268lt726mb5eso11038e5kq5.apps.googleusercontent.com",
"clientSecret": "qrlq907w4Owz5FRZv52momPd",
"propertyName": "googleToken",
"quiet": false,
"scope": ["https://www.googleapis.com/auth/youtube"]
}
},
"env:development": {},
"env:test": {},
"env:production": {},
"os:android": {},
"os:blackberry": {},
"os:ios": {},
"os:mobileweb": {},
"dependencies": {
"ytPlayer": "1.0"
}
}
- In one of your controllers, require the library and initialize it. Example:
var YouTube = require('youtube');
YouTube.init();
- Make your first call! Example:
YouTube.send({
operation : "activities",
properties : {
part : "snippet,contentDetails",
home : "true",
maxResults: "20"
},
callback : function(data) {
alert("Hooray, data! " + data);
}
});
Take a look at the included example app for further details on using the library and parsing results.
TiYouTubeAPI requires googleAuth.js (made by Miroslav Magda). The example app includes the ytPlayer 1.0 widget built by Bob Sims.