How to suppress the action of creating (by default) creating Facebook by creating an Open Graph object

I am creating a photo app for iOS. I have a custom action-type “take a picture” pair defined in my application. First, I create a photo object (I have a custom image, and I first upload a photo and get an intermediate level URI, after which this code):

NSMutableDictionary *imageData = [NSMutableDictionary dictionaryWithDictionary: @{ @"url" : stagingURL, @"user_generated" : @"true", }]; NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPostWithType:@"tonerapp:photo" title:@"photo" image:imageData url:@"http://tonerapp.info" description:title]; //post the object to facebook [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if(result != nil){ NSString* resultID = [result objectForKey:@"id"]; NSMutableDictionary<FBGraphObject> *actionDict = [FBGraphObject graphObject]; actionDict[@"photo"] = resultID; [self postTakeActionToFacebookWithOpenGraphObject:actionDict completion:action]; }else{ action(NO); } }]; 

After publishing the object, I will post the “accept” action in the completion handler, as shown above. Here is the code to publish the take action with the photo object:

 -(void)postTakeActionToFacebookWithOpenGraphObject:(NSMutableDictionary<FBGraphObject>*)ogObject completion:(booleanAction)action{ if(self.selectedPlace != nil){ ogObject[@"place"] = [self.selectedPlace id]; } if(self.taggedFriends != nil && self.taggedFriends.count > 0){ ogObject[@"tags"] = self.taggedFriends; } [FBRequestConnection startForPostWithGraphPath:@"me/tonerapp:take" graphObject:ogObject completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if(result != nil){ NSLog(@"oldu"); action(YES); }else{ action(NO); } }]; } 

Here is the result:

posted two actions

First, the "post" action is created, then the "accept" action is applied to the photo. I need to get rid of the post action. More strangely, the My Open Chart panel looks like this:

default actions added automatically

I delete the Object type and the Publish action, but each time they are added to my actions again. I suspect that something that I am doing wrong would cause the default message creation problem, and the default pairs are added to my panel. I go to the settings of my application and change the action of subscribing (creating) my photo type:

creation action setting

Then I will send the photo again. Although my create action takes, the post action is created:

post action

But this time I can’t create any action to “accept”. He does not cope with this answer:

 body = { error = { code = 1611231; message = "A post action for this object already exists."; type = Exception; }; }; code = 500; 

Shouldn't it be the other way around? Shouldn't I mess this up if I haven't set a default action for my custom action? I also tried to create the photo object “on the fly” (without “sending” it first and sending the JSON object data directly to the “take” action, which, apparently, is a natural way to execute it), but this is also not the case as in this example: Facebook object code example. . Am I missing something, or is something serious wrong with the Open Graph API?

Thanks,

Can.

UPDATE: I have migration on July 2013

+4
source share
2 answers

If you create an open graph object (open to the user) through the Object API (which you use with startForPostOpenGraphObject, as well as through the general dialogue), then the "Mail" action will be created. The only way is to place your own open graph objects.

Think of it this way, what you really do is actually two separate operations.

  • You create an open graph object (i.e. you "sent" the object)
  • You create an open graph action (that is, an accept action) that acts on an object

Each of them will lead to a separate action in the activity log. This separation is important because you can reuse the same object in a different action, and it should be displayed in the user's activity log because it belongs to the user.

See also https://developers.facebook.com/docs/opengraph/using-object-api/

+6
source

@can Poyrazoglu

You should use these methods if you do not create a history for each message. If there are several images from the same message, he will group the image and make the album as a whole only instead of creating a separate record.

 NSMutableDictionary* params = [[NSMutableDictionary alloc] init]; [params setObject:@"your custom message" forKey:@"message"]; [params setObject:UIImagePNGRepresentation(_image) forKey:@"picture"]; _shareToFbBtn.enabled = NO; //for not allowing multiple hits [FBRequestConnection startWithGraphPath:@"me/photos" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (error) { //showing an alert for failure [self alertWithTitle:@"Facebook" message:@"Unable to share the photo please try later."]; } else { //showing an alert for success [UIUtils alertWithTitle:@"Facebook" message:@"Shared the photo successfully"]; } _shareToFbBtn.enabled = YES; }]; 
-one
source

Source: https://habr.com/ru/post/1492588/


All Articles