Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Engelbert Ebalo
3,697 PointsAuthenticating then displaying json received from Treebook app
I am trying to integrate the things I've learned from the Ruby on Rails track with Treebok with the iOS track of getting data off of the web.
Since there is authentication on the Treebook site, how can i pass those credential in the iOS app to the treebook site so I can get the json of items (statuses, friends list, etc)
2 Answers
Amit Bijlani
Treehouse Guest TeacherYou would have the user enter the username and password and post it to the server where Treebook is hosted. To submit the username/password use the networking library called AFNetworking. Once you submit that information you can use AFNetworking to download and parse the JSON data.
Mike Bronner
16,395 PointsDid the Ruby track let you download from Treehouse using your credentials? For this to work properly, Treehouse needs to expose an API (I haven't tried this, so I don't know if they do). The API would then have a handshake method, and a data retrieval method and then return the JSON data. Short of that, you would have to load the web page in your programming and extract the information from there, would be pretty tedious (this method is known as Screen Scraping). :)
Sorry I don't have a programatic solution, but this may help get you on the right track.