Facebook - How to get a list of friends

1

Index

Stats

9,593 visits, 18,413 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 23 Jan, 2013. Last updated 19 Feb, 2019

Contents of Edittime.js

Edittime.js contains five major sections. You only need concern yourself with the first four sections. Information on the last section can be gleaned by reading comments found in the Scirra Construct 2 plugins.

Plugin Settings -

The first section is a Construct 2 PlugIn Settings data. You will only need to change important fields like "name", "id", "version", while the rest are entirely optional; it's good practice to update both "author" and "help url" so that others can contact you for help.

Make sure you use something unique for "name" and "id" so that your new plugin will be able to co-exist with the default Facebook plugin.

    function GetPluginSettings()
    {
    	return {
    		"name":			"Facebook",
    		"id":			"Facebook",
    		"version":		"1.0",
    		"description":	"Access Facebook API features.",
    		"author":		"Scirra",
    		"help url":		"http://www.scirra.com/manual/112/facebook",
    		"category":		"Platform specific",
    		"type":			"object",			// not in layout
    		"rotatable":	false,
    		"flags":		pf_singleglobal,
    		"dependency":	"channel.html"
    	};
    };

The second, third, and fourth sections are demarcated by the comments that say "Conditions", "Actions", and and "Expressions". The code below provides an extract from each section of the Facebook plugin:

Conditions -

    AddCondition(8, cf_trigger, "On ready", "Facebook", "On ready", "Triggered when the Facebook API has loaded and is ready to be used.", "OnReady");

Actions -

    AddStringParam("Name", "The name of the app that will appear in the Share dialog.");
    AddStringParam("Caption", "The caption appearing beneath the name in the Share dialog.");
    AddStringParam("Description", "The description appearing beneath the caption in the Share dialog.");
    AddStringParam("Picture URL (optional)", "The URL of an image on your server to use on the Share dialog.  Must include the http://.  Defaults to the exported logo.png.");
    AddAction(5, 0, "Prompt to share this app", "Prompt (no permissions required)", "Prompt to share this app (<i>{0}</i>, <i>{1}</i>, <i>{2}</i>, <i>{3}</i>)", "Bring up a dialog where the user can share a link to the app on their wall or choose to cancel.", "PromptToShareApp");

Expressions -

    AddExpression(7, ef_return_number, "Get user ID", "Facebook", "UserID", "Get the user's ID, which is different even for users with the same name.");

For obvious reasons, the AddFoo functions define either a new Condition, Action, or Expression. As they are more or less similar, let's go through each argument passed to the three function types:

    AddCondition:
    (id, // any positive integer to uniquely identify this condition
    flags, // (see docs) cf_none, cf_trigger, cf_fake_trigger, cf_static, cf_not_invertible, cf_deprecated, cf_incompatible_with_triggers, cf_looping
    list_name, // appears in event wizard list
    category, // category in event wizard list
    display_str, // as appears in event sheet - use {0}, {1} for parameters and also <b></b>, <i></i>
    description, // appears in event wizard dialog when selected
    script_name); // corresponding runtime function name

Note: For AddCondition, you will be using either 0 (cf_none) or cf_trigger for the flags argument. cf_trigger means some condition will trigger the action to become true (usually when data is available), while cf_none means the condition is checked normally - that is to say, it is not dependent on a trigger.

    AddAction:
    (id, // any positive integer to uniquely identify this action
    flags, // (see docs) af_none, af_deprecated
    list_name, // appears in event wizard list
    category, // category in event wizard list
    display_str, // as appears in event sheet - use {0}, {1} for parameters and also <b></b>, <i></i>
    description, // appears in event wizard dialog when selected
    script_name); // corresponding runtime function name

Note: For AddAction, you will be using 0 (af_none) for the flags argument.

    AddExpression:
    (id, // any positive integer to uniquely identify this expression
    flags,	// (see docs) ef_none, ef_deprecated, ef_return_number, ef_return_string, ef_return_any, ef_variadic_parameters (one return flag must be specified)
    list_name, // currently ignored, but set as if appeared in event wizard
    category, // category in expressions panel
    exp_name, // the expression name after the dot, e.g. "foo" for "myobject.foo" - also the runtime function name
    description); // description in expressions panel

Note: For AddExpression, you will most likely be using either ef_return_number (to retrieve a value) or ef_return_string (to retrieve a text string).

Before we end this section, you may have noticed that for AddAction (and AddExpression), you can also define parameters. You will likely be adding a number or string argument when making a Facebook call, so you will need to use AddNumberParam or AddStringParam. A definition of all available parameter types is provided below:

    AddNumberParam(label, description [, initial_string = "0"]) // a number
    AddStringParam(label, description [, initial_string = "\"\""]) // a string
    AddAnyTypeParam(label, description [, initial_string = "0"]) // accepts either a number or string
    AddCmpParam(label, description) // combo with equal, not equal, less, etc.
    AddComboParamOption(text) // (repeat before "AddComboParam" to add combo items)
    AddComboParam(label, description [, initial_selection = 0]) // a dropdown list parameter
    AddObjectParam(label, description) // a button to click and pick an object type
    AddLayerParam(label, description) // accepts either a layer number or name (string)
    AddLayoutParam(label, description) // a dropdown list with all project layouts
    AddKeybParam(label, description) // a button to click and press a key (returns a VK)
    AddAnimationParam(label, description) // a string intended to specify an animation name
    AddAudioFileParam(label, description) // a dropdown list with all imported project audio files

Now that you have a rough idea of what's inside edittime.js, let's take a look at the changes you shall be making in runtime.js. Once you have added new functions in runtime.js, you shall be returning to edit this file. We shall be seeing this in the next section.

  • 0 Comments

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