Danbooru

Danbooru for Android forbidden error

Posted under General

I'm currently attempting to create an Android application for Danbooru with some success. I've run into a weird problem involving 403 forbidden. When I access /post/index.json using Firefox, I was successful in getting the JSON array. I was also successful when I accessed /post/index.json?limit=12&page=3.

On the Android emulator for Eclipse, accessing /post/index.json gives me the 403 forbidden error. I was able to access /tag/index.json. I've read that Danbooru rejects all requests with a certain header and I'm wondering if I have to modify my header request and what header to modify if I do.

I pasted my code below. The url is currently pointing to http://danbooru.donmai.us/post/index.json.

HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(new HttpPost(url));
HttpEntity entity = response.getEntity();
Log.w("w",response.getStatusLine().getReasonPhrase() +"" + response.getStatusLine().getStatusCode());
String jsonString = JsonParse.convertStreamToString(entity.getContent());

Updated by RaisingK

picnic said:
You may want to give forum #45741 a good look at. This project appears to have stalled a year and a half ago and may have elements useful to yours.

I've given it a look and I haven't been any more successful using his method to fetch the images. When I use his app, I don't even get a 403 forbidden error. It just gives me an empty string when I fetch the images.

ghostrigger said:
have you tried passing your login credentials to index.json (username and hashed password)? forum #78144 was about a different language, but i would guess had a similar authentication problem.

It seems like inputting my login credentials worked. Thanks, that helped a lot.

Is there a way to get it to work without that?

meenter said:
It seems like inputting my login credentials worked. Thanks, that helped a lot.

Is there a way to get it to work without that?

No. Certain pages and API queries are restricted to members only, and the Post API is one of them.

1