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
Charles Brown
2,135 PointsHow to Add my own Blog Url????
I am confused, I finished the blog reader application it works perfectly fine for the TeamTreehouse blog("http://blog.teamtreehouse.com/api/get_recent_summary/?count=" + NUMBER_OF_POSTS) So why cant I place my own blog url? I have tried four different Blog urls non of them were successful except Treehouse. is there something different I need to do? Any help or advice would be greatly appreciated
Charlie Brown
4 Answers
Thomas Jaede
Courses Plus Student 7,633 PointsIt happens here on the onListItemCIick() method. The code from the project files look like this:
JSONArray jsonPosts = mBlogData.getJSONArray("posts");
JSONObject jsonPost = jsonPosts.getJSONObject(position);
String blogUrl = jsonPost.getString("url");
Try replacing the jsonPost.getString("url), with the url of your blog. Should look something like this:
JSONArray jsonPosts = mBlogData.getJSONArray("posts");
JSONObject jsonPost = jsonPosts.getJSONObject(position);
String blogUrl = "http://charlesblog.wordpress.com"; //Put your actual blog URL here.
The list won't look any different, but every time you click a list item, your blog should appear in the web view.
Thomas Jaede
Courses Plus Student 7,633 PointsHi Charles,
The (http://blog.teamtreehouse.com/api/get_recent_summary/) URL uses Treehouse's api to retrieve blog post data . It isn't returning blog posts so much as it's returning metadata about blog posts. Try placing the treehouse URL in your browser, that may make it more clear what the difference is. I posted a modified example of the returned metadata below.
{
"status": "ok",
"count": 1,
"count_total": 1743,
"pages": 175,
"posts": [
{
"id": 23560,
"url": "http://blog.teamtreehouse.com/improve-coding-confidence",
"title": "5 Excellent Ways to Improve Your Coding Confidence",
"date": "2014-05-29 14:49:22",
"author": "Andrew Chalkley",
"thumbnail": "http://blog.teamtreehouse.com/wp-content/uploads/2014/05/codingconfidence-150x150.jpg"
}]
}
My guess is you're attempting to reference your blog post using the URL that displays when you access that blog on a webpage. That would be analogous to the 'url' property in in the sample above.
Charles Brown
2,135 PointsThanks Thomas I really appreciate your help and time , so I need to figure out how to get a wordpress/blogger api this is a bummer.
Thomas Jaede
Courses Plus Student 7,633 PointsYou're very welcome, Charles. And you may not have to work with the api if you would just like to hardcode the URL to your blog. The issue was that you were attempting to hardcode it in the wrong place. I haven't taken this Android tutorial so I can't be as specific as I'd like, but I'll give it a shot.
In your code, do you see where the blog object [the one you create with this constructor => blog("http://blog.teamtreehouse.com/api/get_recent_summary/?count=" + NUMBER_OF_POSTS) ] uses the url property? Try hardcoding the getter of the url property to your blog's url.
Charles Brown
2,135 PointsHey thanks again Thomas I have tried to hardcode it but that didn't work either. I think Hard coding an application like this would have been the best approach in the first place. Well at least we've tried, Thanks again Thomas I really appreciate your time and help.
Charlie Brown