Game Development Reference
In-Depth Information
Step 10. To get data from other Facebook Graph APIs, more functions can
be added into the Facebook UFacebook.cs file in Projects > Plugins. This
file is in C# so unless you know what you are doing, it is recommended
that you don't change this file.
However, for illustrative purposes, a function called GetUserFriends() has
been added. This calls the Facebook Graph API that returns the current user's
friends. The URL to achieve this is shown at http://developers.facebook.com/
docs/reference/api/ and is https://graph.facebook.com/me/ friends ?access_
token=… “friends” in this case is the keyword for data retrieval. Note that in
the API documentation you can get data for anything from news feeds, likes,
and photos. All you would need to do is copy the GetUserFriends() function in
the C# file, give it another name, and change the word “friends” for something
else such as “groups.” As an example, the C# function for GetUserGroups()
would be
public static string GetUserGroups(string user)
{
try
{
FacebookAPI api = new FacebookAPI(MagicToken);
Facebook.JSONObject request = api.Get("/" + user +
"/ groups ");
LastRequest = request.ToDisplayableString();
return request.ToDisplayableString();
}
catch
{
return null;
}
}
Step 11. To call the GetUserFriends() function and display the
information in the text field, modify the interface.js code to reflect
Listing 8.16 .
Listing 8.16 Requesting a User's Friend List from Facebook
var t: Texture2D;
...
function RequestUserFriends()
{
if(MagicToken != "")
{
 
Search Nedrilad ::




Custom Search