iphone: unable to post image on wall (facebook) -


i trying upload image facebook , gam getting image id uploaded in facebook , after getting id trying create request appending photo id in grap library everytime getting error. code worked failing

    nsstring *message = [nsstring stringwithformat:@"for test --> think uploaded !"];      nsurl *url = [nsurl urlwithstring:@"https://graph.facebook.com/me/photos"];     asiformdatarequest *request = [asiformdatarequest requestwithurl:url];     [request addfile:savedimagepath forkey:@"file"];     [request setpostvalue:message forkey:@"message"];     [request setpostvalue:_accesstoken forkey:@"access_token"];     [request setdidfinishselector:@selector(sendtophotosfinished:)];      [request setdelegate:self];     [request startasynchronous];   }      - (void)sendtophotosfinished:(asihttprequest *)request {     // use when fetching text data     nsstring *responsestring = [request responsestring];      nsmutabledictionary *responsejson = [responsestring jsonvalue];     nsstring *photoid = [responsejson objectforkey:@"id"];     nslog(@"photo id is: %@", photoid);      nsstring *urlstring = [nsstring stringwithformat:                            @"https://graph.facebook.com/%@?access_token=%@", photoid,                             [_accesstoken stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]];     nsurl *url = [nsurl urlwithstring:urlstring];     asihttprequest *newrequest = [asihttprequest requestwithurl:url];     [newrequest setdidfinishselector:@selector(getfacebookphotofinished:)];      [newrequest setdelegate:self];     [newrequest startsynchronous];  }      - (void)getfacebookphotofinished:(asihttprequest *)request {     nsstring *responsestring = [request responsestring];     nslog(@"got facebook photo: %@", responsestring);      nsmutabledictionary *responsejson = [responsestring jsonvalue];         nsstring *link = [responsejson objectforkey:@"link"];     if (link == nil) return;        nslog(@"link photo: %@", link);      nsurl *url = [nsurl urlwithstring:@"https://graph.facebook.com/me/feed"];     asiformdatarequest *newrequest = [asiformdatarequest requestwithurl:url];     [newrequest setpostvalue:@"i'm learning how post facebook iphone app!" forkey:@"message"];     [newrequest setpostvalue:@"check out tutorial!" forkey:@"name"];     [newrequest setpostvalue:@"this tutorial shows how post facebook using new open graph api." forkey:@"caption"];     [newrequest setpostvalue:@"from ray wenderlich's blog - blog iphone , ios development." forkey:@"description"];     [newrequest setpostvalue:@"http://google.com" forkey:@"link"];     [newrequest setpostvalue:link forkey:@"picture"];     [newrequest setpostvalue:_accesstoken forkey:@"access_token"];     [newrequest setdidfinishselector:@selector(posttowallfinished:)];      [newrequest setdelegate:self];     [newrequest startasynchronous];  }      - (void)posttowallfinished:(asihttprequest *)request {     nsstring *responsestring = [request responsestring];      nsmutabledictionary *responsejson = [responsestring jsonvalue];     nsstring *postid = [responsejson objectforkey:@"id"];     nslog(@"post id is: %@", postid);      uialertview *av = [[[uialertview alloc]                          initwithtitle:@"sucessfully posted photos & wall!"                          message:@"check out facebook see!"                         delegate:nil                          cancelbuttontitle:@"ok"                         otherbuttontitles:nil] autorelease];     [av show];  } 

error is

-jsonvalue failed. error trace is: ( "error domain=org.brautaset.json.errordomain code=4 \"valid fragment, not json\" userinfo=0x6078ae0 {nslocalizeddescription=valid fragment, not json}"

please enlighten me on this.

regards ankit


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -