facebook_dialog(graph_path, ds_map_parameters, ds_map_return)
Argument Description graph_path The part of the social graph to interact with ds_map_parameters The ds_map with the information to send. ds_map_return The ds_map to receive (-1 for none).
A Facebook dialog is the way in which Facebook asks the user to give comments and information and they not need any additional permissions because they require user interaction. For example, it can be used to send friend request or to post a comment to a wall. The "graph_path" argument is where you define the part of the graph you wish to access, and the exact path can be defined using the terms outlined in the Facebook Dialogues Overview.
The next argument is slightly more complex as it requires you to have created and filled a ds_map with the correct information which GameMaker Studio 2 will then convert into json automatically when sent to the Facebook Api. The information that you put in this map will depend very much on which path you choose to use and a complete list of all possible values can be found here. An example of how this map is structured can be seen in the code example supplied below.
Finally, we have an argument for storing any information that Facebook has sent back from the graph request. This information comes in the form of json which GameMaker Studio 2 converts into a ds_map. For this to work correctly, you must have created a ds_map previously, and if that map has been used elsewhere and already contains some key/value pairs it will be cleared by this function before the Facebook data is added. It is very important that you read the Facebook documentation on possible return values so that you know exactly what to expect. Thankfully Facebook have a Graph Api Test Page where you can check different graph paths and see exactly what information they will return.
NOTE: The user does not need to be logged in to use this function as the log in dialogue will be shown as part of the dialogue request.
interactiveMap = ds_map_create();
ds_map_add(interactiveMap, "picture", "http://MacSweeneygames.com/Clown.jpg");
ds_map_add(interactiveMap, "link", "http://MacSweeneygames.com/");
ds_map_add(interactiveMap, "name", "Catch The Clown");
ds_map_add(interactiveMap, "caption", "MacSweeneygames.com");
ds_map_add(interactiveMap, "description", "Play Catch the clown now on MacSweeney Games!");
facebook_dialog("feed", interactiveMap, -1);
The above code will create a ds_map and store its index in the local variable "interactiveMap". This map is then filled with the necessary key/value pairs to generate an interactive wall post. Next the facebook_dialog will open a window asking the user to add a message to be sent along with the rest of the information and this will all be published to the users wall. Finally the ds_map is deleted to free memory.