0

I'm using the latest Facebook iOS SDK to publish an action to Open Graph.

Now, on my server side, I had a bug in the object creation, affecting the title of the object.

I now fixed the bug - and I verified it both in the Object Debugger tool, and also I can see it fixed for new objects I preform actions on in my app.

However, the object I originally created when an action was published from my app still has the malformed title when I publish new actions on it.

I managed to find the ID of the problematic object using the Graph API Explorer, but had no luck in deleting it (got a "(#3) App must be on whitelist" exception).

Any ideas how I can somehow force the object to get re-created?

EDIT:

I've tried both methods suggested in James's answer and this answer to a similar question, but could not get my existing and newly posted actions on the malformed object to refresh. The debugger does seem to create a scraped object with fixed data, but it does not update the original object, rather then giving me a new one (I can see there's a new ID in the "Graph API:" URL in the URLs section in the bottom of the object debugger.

EDIT:

I finally found a solution that works for new actions (not existing ones). See answer below.

Community
  • 1
  • 1
yonix
  • 11,665
  • 7
  • 34
  • 52

3 Answers3

2

Using the debugger forces Facebook to rescrape the URL, so that should bust the cache. You can also programatically force a rescrape by adding 'scrape=true' as a parameter. Something like...

POST https://graph.facebook.com

id=http://mysite.com/myobject
&
scrape=true&access_token=234876AB6865...

See if that helps

James Pearce
  • 2,332
  • 15
  • 14
  • It does seem to scrape the object, but it doesn't change the existing ID the actions are pointing to, but creates a new one instead. Existing actions on this object, and new one from my app, are still pointing to the old malformed object... – yonix Nov 06 '12 at 14:42
1

Following the suggestion in this answer for a similar question, I finally figured out that if I change my iOS app's code to set the URL for the FBGraphObject to contain: &fbrefresh=CAN_BE_ANYTHING, the newly posted actions are posted with an updated object.

This still doesn't fix existing actions (they are still pointing to a malformed object), but at least this way I can ensure new posted actions are pointing to a refreshed object.

Community
  • 1
  • 1
yonix
  • 11,665
  • 7
  • 34
  • 52
0

First of all, you should have information about OpenGraph on your web page. And Facebook caches meta information for each URL. If you share the same URL, Facebook will use the information it already cached, even if it was modified. Therefore, you should explicitly update the cache information for the URL. If you are using Objective-C, you can use the following code to update the cache information.

iOS, Objective-C

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    //Example..
    NSString *targetId = @"{The URL for update}";
    [self updateFacebookCache:targetId];
}

- (void)updateFacebookCache:(NSString *)targetId {
    NSString *url = @"https://graph.facebook.com";

    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:targetId forKey:@"id"];
    [params setObject:@"true" forKey:@"scrape"];

    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

    [manager POST:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"success!");
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error: %@", error);
    }];
}
hooni
  • 249
  • 3
  • 9