简体   繁体   中英

Facebook SDK request api

I have been reading the Facebook documentation . The Facebook documentation for asking/sending gifts mentioned a YOUR_OBJECT_ID for this call:

FB.ui({method: 'apprequests',
  message: 'Take this bomb and blast your way to victory!',
  to: 'RECIPIENT_USER_ID'
  action_type:'send',`enter code here`
  object_id: 'YOUR_OBJECT_ID', // Where do I get this ?
  data: 'Friend Smash Custom Tracking 1'
}, function(response) {
console.log(response);
}); 

How do I get get it? I have already created my object inside Open Graph, but there is no object id specified. Do I need to initiate a create request for the user from my app for that object or how is this suppose to work?

The request_object_id is what you will get back from the dialog, after the user sent the gift – it is part of the dialog's return value. It is simply the identifier for the request that was send.

https://developers.facebook.com/docs/games/requests/v2.1#response

You can use it to read details of the request back from the API.

OK, so since this is about the object id that one can pass to the dialog:

That documentation section already links to https://developers.facebook.com/docs/sharing/opengraph/custom , where this is explained in more detail.

Basically, you need to set up your own Open Graph action and Open Graph object. This will define what your object is, and what players of the game can do with it.

Open Graph objects can be created in two ways:

  1. You can host them yourself. To do this, you simply provide URLs to HTML pages which include the Open Graph meta data that specifies the object property values. Facebook will then read the meta data from those URLs (“scraping”). In that case, you would simply pass the object URL to the dialog as object_id .

  2. You can use the Object API to create objects that Facebook will host for you. These can either be “app-owned” or “user-owned” – depends on if the are specific to a certain user, or “common” objects to be used by all users of your app. Creating an object via that API will give you back an object id, that you can then pass to the dialog.

If you are not familiar with the whole Open Graph Story concept yet, then I recommend you start by having a look at the whole Open Graph section, https://developers.facebook.com/docs/sharing/opengraph

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM