1

I am running into difficulty sharing an article link from my iOS app to Facebook using the Facebook SDK FBWebDialogs class. The URL of the link includes query string parameters, which I am URL encoding from my iOS app before sending to Facebook.

Here is an example link that I am trying to share:

http://www.foo.com/message.html?s=This%20is%20a%20test%20&%20an%20example

Here is what Facebook shows as the link on my timeline:

?s=This+is+a+test+&+an+example

Once the link is published to my Facebook timeline, Facebook appears to be stripping all URL encoding, leaving my query string void of encoding, which causes the destination web app to not receive necessary data. Needless to say, the destination webpage has trouble consuming the query string parameters properly if special characters (&, =, etc) are not encoded properly when linked within the Facebook feed.

What is the proper way to share a link with querystring parameters? Should querystring params be passed as a separate parameter, or should they be denoted somehow within the link url?

Below is the code relevant to setting up the share parameters.

NSString *url_param_str = [NSString stringWithFormat:@"http://www.foo.com/message.html?s=%@", @"This is a test & an example"];

NSString *web_url_param_str = [url_param_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSMutableDictionary *feedParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Sharing an article", @"name",
                                           @"This is a test title", @"description",
                                           @"www.foo.com", @"caption",
                                           web_url_param_str, @"link",
                                           nil];
Octoad
  • 11
  • 3

1 Answers1

0

It looks like that Facebook has decided to scrub url query parameters when using the SLComposeViewController You have to use Facebook Share now.

https://stackoverflow.com/a/32263392/608739

#import <FBSDKShareKit/FBSDKShareKit.h>

FBSDKShareLinkContent  *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL urlWithString:@"http://www.foo.com/message.html?s=This%20is%20a%20test%20&%20an%20example"];
content.contentDescription = @"Text for facebook";
content.contentTitle = @"Results.";

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:self];
Community
  • 1
  • 1
Endama
  • 743
  • 8
  • 25