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

Android

Json feed won't work in the blogreader app

I have follow de blogreader app tutorials, now i want to get my own data.

I made this: http://dev.dennis-adriaansen.nl/

with this: function checkNameExists() { $qry = "SELECT COUNT(*) FROM posts WHERE firstname = 'Dennis'"; $resource = $dblink->query($qry);

$count = mysqli_fetch_array($resource);
$count = $count['0'];

if ($count[0] == 0) {
    return false;
} else {
    return true;
}

}

and change the url in the android project. But firefox json plugin seems to ignor the json code and in android: there was an error getting data from the blog.

3 Answers

Jonathan Baker
Jonathan Baker
2,304 Points

Dennis,

After a quick look at the headers your website is returning, the problem is most likely the fact that the Content-Type header is set to "text/html" instead of "application/json".

curl --head http://dev.dennis-adriaansen.nl
HTTP/1.1 200 OK
Date: Tue, 01 Apr 2014 13:46:29 GMT
Server: Apache/2
Vary: Accept-Encoding,User-Agent
Content-Type: text/html

Try fixing that first and see if it resolves your issues.

JSONVIEW give the following -

 {
status: "ok",
count: 1,
count_total: 1691,
pages: 1,
posts: [
{
id: "1",
title: "dennis",
author: "testlastname"
}
]
}

Thanks guys, i have changed it and now its working fine!