Created
August 24, 2011 01:31
-
-
Save appcdr/1167102 to your computer and use it in GitHub Desktop.
Appcelerator: Facebook photo albums pieces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.Facebook.appid = "134793934930"; | |
Titanium.Facebook.permissions = [ | |
'publish_stream', | |
'read_stream', | |
'user_photos', | |
'friends_photos' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!Titanium.Facebook.loggedIn) { | |
// this will displaty the standard webView login. | |
Titanium.Facebook.authorize(); | |
Titanium.Facebook.addEventListener('login', function(e) { | |
if(e.success) { | |
// FUNCTION TO MAKE API CALL GOES HERE | |
return; | |
} else if(e.error || e.cancelled) { | |
return; | |
} | |
}); | |
} else { | |
// FUNCTION TO MAKE API CALL GOES HERE TOO!! Called if already authenticated | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.Facebook.requestWithGraphPath( | |
'me/albums', | |
{ | |
fields : 'id,name,cover_photo,count,created_time' | |
}, | |
'GET', | |
function(graphResp) { | |
if(graphResp.success) { | |
if(graphResp.result) { | |
var data = JSON.parse(graphResp.result).data; | |
for (x in data) { | |
Ti.API.debug(JSON.stringify(data[x])); | |
// IMAGE VIEW LOOP CREATION CODE GOES HERE | |
} | |
} | |
} else if(graphResp.cancelled) { | |
alert("User Cancelled"); | |
} else { | |
Ti.API.debug(graphResp.result); | |
} | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imageView = Ti.UI.createImageView({ | |
width:50, | |
height:50, | |
left:10, | |
top:5, | |
bottom:5, | |
album_id:data[/*index of album*/].id, | |
image:'https://graph.facebook.com/'+data[*index of album*/].cover_photo+'/picture?access_token=' + Ti.Facebook.accessToken | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment