Skip to content

Instantly share code, notes, and snippets.

@danro
Forked from atypical/blah.js
Created October 31, 2011 00:00
Show Gist options
  • Save danro/1326617 to your computer and use it in GitHub Desktop.
Save danro/1326617 to your computer and use it in GitHub Desktop.
Read and Clean
function parseTheDashboardData(resp){
var httpStatus = resp.meta.status,
httpMessage = resp.meta.msg,
dashboardPostsArray = resp.response.posts;
for (var i = 0; i < dashboardPostsArray.length; i++){
var current=dashboardPostsArray[i];
var blogName = current.blog_name
, blogID = current.id
, blogPostUrl = current.post_url
, blogPostType = current.type
, blogPostDate = current.date
, blogPostTime = current.timestamp
, blogPostFormat = current.format
, blogReblogKey = current.reblog_key
, blogTagArray = current.tags
, blogLiked = current.liked
, blogNoteCount = current.note_count
, blogCaption = current.caption
, blogPhotos = current.photos
Ti.API.info('blogName: '+blogName);
Ti.API.info('blogID: '+blogID);
Ti.API.info('blogPostUrl: '+blogPostUrl);
Ti.API.info('blogPostType: '+blogPostType);
Ti.API.info('blogPostDate: '+blogPostDate);
Ti.API.info('blogPostTime: '+blogPostTime);
Ti.API.info('blogPostFormat: '+blogPostFormat);
Ti.API.info('blogReblogKey: '+blogReblogKey);
Ti.API.info('blogTagArray: '+blogTagArray);
Ti.API.info('blogLiked: '+blogLiked);
Ti.API.info('blogNoteCount: '+blogNoteCount);
Ti.API.info('cleanedBlogCaption: '+blogCaption.replace( /<[^>]+>/g, '' ));
Ti.API.info('blogPhotos: '+blogPhotos);
// loop thru each photo in the post
for (var j = 0; j < blogPhotos.length; j++){
var photoObj = blogPhotos[j];
// do stuff with photoObj
var photoCaption = photoObj.caption;
// another array for photoObj.alt_sizes
for (var k = 0; k < photoObj.alt_sizes.length; k++){
var altSize = photoObj.alt_sizes[k];
}
// do more stuff with photoObj...
var originalWidth = photoObj.original_size.width;
var originalUrl = photoObj.original_size.url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment