RawMean
RawMean

Reputation: 8717

iOS: Posting a photo to Facebook and small html as caption

Is it possible to upload an image to photo album and include a small html code as caption with it?

I would like to use the new Graph API to do this.

The following code works, but when I set my text variable to an html code, the caption appears as plain text with all the html tags visible.

Also, in the following code, the its.title is completely ignored when item.text is not null.

if (item.shareType == SHKShareTypeImage && item.image)
{   
    if (item.title) 
        NSLog(@"title = %@", item.title);
        [params setObject:item.title forKey:@"caption"];
    if (item.text) {
        NSString *mytext = [NSString stringWithFormat:@"%@\n\nCreated by iPhone app FaceMod: %@", item.text,appURL];
        [params setObject:mytext forKey:@"message"];
    }
    [params setObject:item.image forKey:@"picture"];
    // There does not appear to be a way to add the photo 
    // via the dialog option:
    [[SHKFacebook facebook] requestWithGraphPath:@"me/photos"
                                       andParams:params
                                   andHttpMethod:@"POST"
                                     andDelegate:self];
    [self retain]; //must retain, because FBConnect does not retain its delegates. Released in callback.
    return YES;
}

My understanding is that the way to post html is to using the "action" key:

NSString *actions = [NSString stringWithFormat:@"{\"name\":\"%@ %@\",\"link\":\"%@\"}",
            SHKLocalizedString(@"Get"), SHKCONFIG(appName), SHKCONFIG(appURL)];
[params setObject:actions forKey:@"actions"];

But this does not work either and the "action" html code is ignored and does not appear of Facebook.

Thanks for the help.

Upvotes: 1

Views: 650

Answers (1)

Femi
Femi

Reputation: 64700

No. You can't inject HTML into the caption field: Facebook doesn't let you set HTML for values that are displayed in multiple places. Any HTML you submit will be treated as plain text to prevent any HTML injection attacks or visual style changes.

Upvotes: 2

Related Questions