2

I am creating objects through the open graph object API, and attaching these to published stories. Both the object and the story are created, and FB returns id's as if everything worked out just fine.

However, while submitting the object/story for review it turned out two objects are created (of different object types) even though I only make one HTTP POST request.

Background

  • Our app is using namespace 'mynamespace'
  • We have created a custom open graph object with name 'myobject'
  • We have created a custom open graph action with name 'myaction'

Request details:

1) First we create an object:

POST /me/objects/mynamespace:myobject HTTP/1.1\r\nConnection: close\r\nHost: graph.facebook.com\r\nContent-Length: LENGTH\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n

URI decoded http body:

access_token=TOKEN&object={"url":"http://url.com","title":"My title","image":"https://imageurl.com","description":"My description"}

Response:

"{\"id\":\"123456789\"}"

2) Then we create a story (with this object referenced):

POST /me/mynamespace:myaction HTTP/1.1\r\nConnection: close\r\nHost: graph.facebook.com\r\nContent-Length: LENGHT\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n

URI decoded http body:

access_token=TOKEN&myobject=123456789&fb:explicitly_shared=true&message=User generated message

Response:

"{\"id\":\"12121212121\"}"

Expected result

  • One object of type mynamespace:myobject should be created
  • One story of type mynamespace:myaction should be created

Actual result

  • One object of type mynamespace:myobject is created
  • One story of type mynamespace:myaction is created
  • One object of type Object is created (according to reviewer)
  • One action of type Post is created (according to reviewer)

Only one story turned up in the user feed and in the object browser, but the reviewer told us following: Your action produces more than one published story when the user triggers the action. Users shouldn’t be surprised by multiple stories being published for a single in-app action. The action I took produced a "post" and a "myaction" story.

We had a look under (Open Graph -> Types) and it turned out that each time we make this request an object of type 'Object' and an action of type 'Post' is automatically created/defined! This must be what the reviewer complains about, but we haven't been able to figure out what we're doing wrong!

Any suggestions on how this can be solved is be very much appreciated.

Exact same issue when using the Open Graph API explorer

Turns out the exact same thing happens when creating an object through the Facebook Graph API explorer. When doing so the 'Object' object and the 'Post' action suddenly appears under Open Graph -> Types. Right now I see following reasons to this issue:

  • The object/action/story is set up incorrect in some way
  • The reviewer thought it was an issue when it actually wasn't
  • It's a FB bug

Object(s) created through the Graph API explorer

When creating an object through the Graph API explorer this is the resulting object:

{
  "id": "4324324234234234", 
  "url": "http://url.com", 
  "type": "mynamespace:myaction", 
  "title": "My title", 
  "image": [
    {
      "url": "https://imageurl.com"
    }
  ], 
  "description": "My description", 
  "updated_time": "2013-07-09T14:14:38+0000", 
  "created_time": "2013-07-09T14:14:38+0000", 
  "application": {
    "id": "432423423423", 
    "name": "appname", 
    "url": "https://www.facebook.com/apps/appurl"
  }, 
  "is_scraped": false, 
  "post_action_id": "23423423423423423"
}

The 'post_action_id' seems weird, and when requesting that object I get:

{
  "id": "423423423423", 
  "from": {
    "name": "My name", 
    "id": "234234"
  }, 
  "start_time": "2013-07-09T14:14:38+0000", 
  "end_time": "2013-07-09T14:14:38+0000", 
  "publish_time": "2013-07-09T14:14:38+0000", 
  "application": {
    "name": "appname", 
    "namespace": "mynamespace", 
    "id": "432423423423"
  }, 
  "data": {
    "object": {
      "id": "4324324234234234", 
      "url": "http://url.com", 
      "type": "mynamespace:myaction", 
      "title": "My title"
    }
  }, 
  "type": "og.posts", 
  "likes": {
    "count": 0, 
    "can_like": true, 
    "user_likes": false
  }, 
  "comments": {
    "count": 0, 
    "can_comment": true, 
    "comment_order": "chronological"
  }
}

The fact that the object already has a related og.posts object must be what the review think is the issue here. I still don't understand why this og.posts object automatically shows up as an open graph object though.

4

2 回答 2

0

I'm not sure how this would map to your POSTs, but I was dealing with the same issue on iOS and the problem is posting both the object and the action. If you set the object on the field other of the action (instead of the objectId after posting) only one Activity is created. In my case, instead of doing:

NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[@"title"] = @"Title";
object[@"type"] = @"video.other";
object[@"url"] = url;
[FBRequestConnection startForPostOpenGraphObject:object
                               completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    if (!error && [result objectForKey:@"id"]) {
        NSString* objectId = [result objectForKey:@"id"];
        id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
        action[@"explicitly_shared"] = @"true";
        action[@"other"] = objectId;
        [FBRequestConnection startForPostWithGraphPath:@"me/myNamespace:post"
                                           graphObject:action
                                     completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
         {
             // handle success and failures
         }];
    }
}];

I had to do:

NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[@"title"] = @"Title";
object[@"type"] = @"video.other";
object[@"url"] = url;
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
action[@"explicitly_shared"] = @"true";
action[@"other"] = object;
[FBRequestConnection startForPostWithGraphPath:@"me/myNamespace:post"
                                   graphObject:action
                             completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    // handle success and failures
}];
于 2015-01-16T16:27:11.753 回答
0

这里的问题是,当用户单击您网站上的“和平”按钮时,会发布两个 Open Graph 操作,这违反了我们的政策 - 一个用户操作不应发布多个故事。如果您以 Open Graph 测试用户身份登录并检查活动日志,您将看到以下两个具有相同时间戳的已发布操作:

https://www.facebook.com/100006264788511/activity/1388570951361718 https://www.facebook.com/100006264788511/activity/1388570924695054

您确定您的代码在发布操作时仅对 Graph API 进行一次调用吗?

于 2013-07-10T00:43:32.870 回答