Facebook - How to get a list of friends




5,806 visits, 12,326 views


This tutorial hasn't been translated.


How to request for a "Friend Photo URL"

The second function you will paste in (shown below) serves to retrieve the URL of a specific friend of the player. Copy it and paste it into runtime.js, just before the line which reads "pluginProto.acts = new Acts();" again.

Notice a variable "n" is passed to the function called RequestUserFriendURL on line 1. This is used in line 5 to GET the URL to the picture by making a call to FB.api. The callback function(response) saves the information in fbFriendURL in line 11, and then triggers a condition trigger in line 12.

    Acts.prototype.RequestUserFriendURL = function (n) {
       var responseLength = 0;
       if (this.runtime.isDomFree)
       FB.api('/' + fbFriendsID[n] + '/picture', 'GET', { "access_token": fbAppID + "|" + fbAppSecret }, function(response) {
          if (!response.data)
             console.error("Friend URL failed: " + response);
          fbFriendURL = response.data.url;
          fbRuntime.trigger(cr.plugins_.FacebookGW.prototype.cnds.OnFriendURLReceived, fbInst);
          if (!response || response.error) {
          } else {

Because of line 11, we must declare the new variable in your code. Search for the following line "function onFBLogin()" in runtime.js and insert the following declaration in the code before the line.

    var fbFriendURL = "NO URL";

The trigger condition function is pasted before the following line "pluginProto.cnds = new Cnds();".

    Cnds.prototype.OnFriendURLReceived = function ()
       return true;

To retrieve the URL information, you insert in the following function before "pluginProto.exps = new Exps();".

    Exps.prototype.FriendURL = function (ret) {

OK, now save runtime.js and fire up edittime.js. Make the following changes to the relevant sections for Actions, Conditions, and Expressions.

    AddNumberParam("Index of Friend", "The Friend URL to retrieve.");

AddAction(13, 0, "Request friend URL", "Friends info (no permissions required)", "Request friend URL: <b>{0}</b>", "Request Request friend URL, triggering 'on friend URL available' when the info is received.", "RequestUserFriendURL");

    AddCondition(10, cf_trigger, "On Friend URL available", "On Friends Info available", "On Friends Info available", "Triggered after the 'RequestUserFriendURL' action.", "OnFriendURLReceived");

    AddExpression(17, ef_return_number, "Get Friend URL", "Facebook", "FriendURL", "Get the Friend URL requested earlier.");


  • Order by
Want to leave a comment? Login or Register an account!