Wednesday, 18 September 2013

REDDIT api - Couldnt able to submit a link to reddit using http://www.reddit.com/api/submit?

REDDIT api - Couldnt able to submit a link to reddit using
http://www.reddit.com/api/submit?

I am trying to post a link to reddit using api in android but its
returning a json response like below
{"json": {"errors": [["USER_REQUIRED", "please login to do that", null]]}}
Here is my peice of code
response2=UrltoValue.getValuefromUrl("http://www.reddit.com/api/login"+"?api_type="+"json"+"&passwd="+"********"+"&user="+"sudheer21");
try {
jo1=new JSONObject(response2);
jo2=jo1.getJSONObject("json");
for(int i=0;i<jo2.length();i++)
{
if(i==1)
{
jo3=jo2.getJSONObject("data");
modhash=jo3.getString("modhash");
}
}
response=UrltoValue.getValuefromUrl("http://www.reddit.com/api/submit"+"?api_type="+"json"+
"&captcha="+""+"&extension="+""+"&iden="+""+"&kind="+"link"+"&resubmit="+"false"+"&save="+"false"+"&sendreplies="+"true"
+"&sr="+"science"+"&text="+"Havetodo"+"&then="+"excellentpost"+"&title="+"&uh/X-Modhashheader="+modhash+
"&url="+"http://www.heraldsun.com.au/technology/sci-tech/geniuses-predict-how-the-world-will-end-and-how-to-avoid-it/story-fni0c0qs-1226718860033");
please find me a solution

No comments:

Post a Comment