简体   繁体   中英

iphone facebook integration application response error

When I tried to post on wall of facebook in my iphone application I was getting the following message in the message dialog.

Application response error.
The attachment was either missing or its improperly formatted. you can see this because you are one of the developers of the app.

Here is the code I have used for posting on facebook wall

FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt=@"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"Testing"];
[[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:[NSDictionary dictionaryWithObjectsAndKeys:@"AppName",@"caption",nil] dataParam:UIImageJPEGRepresentation([UIImage imageNamed:@"AppImage.png"],1.0)];
[dialog show];

I've found the answer dialog.attachment is string that should be in a proper format having all the necessary fields like appname,hyperlink,description,media for images etc and properties. It wont be enough if it is just a simple string.

dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"AppName\",""\"href\":\"Hyperlink\",\"description\"‌ ​ :\"DescriptionOfApp\",""\"media\":[{\"type\":\"image\",""\"src\":\"HyperlinkOfApp‌ ​ Image\",""\"href\":\"Hyperlink\"}],""\"properties\":{\"PropertiesIfAny":{\"text\"‌ ​:\"Property\",\"href\":\"Hyperlink\"}}}"]; 

Now its working fine.

I think there is problem in the following code

[NSDictionary dictionaryWithObjectsAndKeys:@"AppName",@"caption",nil]

you should enter the value and key like this

[NSDictionary dictionaryWithObjectsAndKeys:value1,key1,value2,key2,...,nil]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM