继续使用Netlog

还有

Developer / Documentation / Netlog Extensions to OpenSocial

Introduction

This is the API reference for Netlog's extensions to the OpenSocial API.


To use any of these extensions you need to add the following to the <ModulePrefs> section at the start of your XML specification:

<Require feature="netlog" />

(you might also want to have a look at the documentation about the Credits extension, translating your app or the OpenSocial REST API)


API Reference

Static Class Netlog

Namespace for the Netlog extensions to OpenSocial

Static Class Netlog.Music

Namespace for the Netlog Music extension to OpenSocial

Method Summary

<static> requestSong(artist, title, opt_callback, opt_params)

Request Netlog for a certain song

Method Detail

requestSong

<static> requestSong(artist, title, opt_callback, opt_params)

Request Netlog for a certain song

Parameters:

String artist - Artist of the song

String title - Title of the song

Function opt_callback - The function to call once the request has been processed; This function will be passed one parameter, an opensocial.ResponseItem. The error code will be set to reflect whether there were any problems with the request. If there was no error, a song has been found. The data on the response item will be set. It will be a Netlog.Music.Song object reflecting the song requested.

Map.<Netlog.Music.Player.Option, Object> opt_params - Optional parameters for the player. Defaults to: height (20), width (20), color (#FFFFFF)

Class Netlog.Music.Player

Used to represent the player related to a certain song

Method Summary

String getHTML()

Get the HTML that represents the player

object getOption(key, opt_params)

Get the option for this player that is associated with the specified key

Method Detail

getHTML

String getHTML()

Get the HTML that represents the player

Returns:

String HTML representing the player

getOption

String getOption(key, opt_params)

Get the option for this player that is associated with the specified key

Parameters:

String key - The key to get data for; see the Netlog.Music.Player.Option class for possible values

Map.<opensocial.DataRequest.DataRequestFields, Object> opt_params - Additional params to pass to the request.

Returns:

object The option

Static Class Netlog.Music.Player.Option

All of the options a player can have

Field Summary

<static> object COLOR

A string representing the color of the player

<static> object HEIGHT

An integer representing the height of the player

<static> object WIDTH

An integer representing the width of the player

Field Detail

COLOR

<static> object COLOR

A string representing the color of the player. Has to be in hexadecimal format: e.g. white: "#FFFFFF"

HEIGHT

<static> object HEIGHT

An integer representing the height of the player.

WIDTH

<static> object WIDTH

An integer representing the width of the player.

Class Netlog.Music.Song

Used to represent a certain song on Netlog

Method Summary

object getField(key, opt_params)

Get the data for this player that is associated with the specified key

Method Detail

getField

object getField(key, opt_params)

Get the data for this player that is associated with the specified key

Parameters:

String key - The key to get data for; see the Netlog.Music.Song.Field class for possible values

Map.<opensocial.DataRequest.DataRequestFields, Object> opt_params - Additional params to pass to the request.

Returns:

object The data

Static Class Netlog.Music.Song.Field

All of the fields a song can have

Field Summary

<static> object ARTIST

A string defining the artist of the song

<static> object PLAYER

Player associated to the song, specified as a Netlog.Music.Player

<static> object TITLE

A string defining the title of the song

Field Detail

ARTIST

<static> object ARTIST

A string defining the artist of the song

PLAYER

<static> object PLAYER

Player associated to the song, specified as a Netlog.Music.Player

TITLE

<static> object TITLE

A string defining the title of the song

Class Netlog.Events

Namespace for the Netlog Events extension to OpenSocial

Method Summary

<static> newFetchFriendsEvents(idSpec, opt_params, callback)

Fetches Events from the idSpec's friends

<static> newFetchUserEvents(idSpec, opt_params, callback)

Fetches Events from the idSpec

<static> newFetchEventOwner(eventID, callback)

Fetches the owner of an event

<static> newFetchEvents(params, callback)

Fetches events according to the params

<static> newFetchCategories(callback)

Fetches all categories available to events

<static> newFetchEventDetails(eventID, callback)

Fetches details of an event

<static> newFetchEventAttendees(eventID, params, callback)

Fetches people attending an event

Method Detail

newFetchFriendsEvents

newFetchFriendsEvents(idSpec, opt_params, callback)

Fetches Events from the idSpec's friends

Parameters:

int idSpec - The numerical userID.

Array opt_params - Optional parameters: start and limit

function callback - A callback function to receive the data from the request.

Example:

 <script type="text/javascript">
 window.onload = function() {
 Netlog.Events.newFetchFriendsEvents(222, { 'start' : 10 }, receiveResults);
 };
 function receiveResults(response) {
 console.log(response);
 }
 </script>
 

newFetchUserEvents

newFetchUserEvents(idSpec, opt_params, callback)

Fetches Events from the idSpec

Parameters:

int idSpec - The numerical userID.

Array opt_params - Optional parameters: start and limit

function callback - A callback function to receive the data from the request.

newFetchEventOwner

newFetchEventOwner(eventID, callback)

Fetches the owner of an event.

Parameters:

int eventID - The numerical eventID specifying the event.

function callback - A callback function to receive the data from the request.

newFetchEvents

newFetchEvents(params, callback)

Fetches events according to the params.

Parameters:

Array params - The params to filter between the events: date, country, region, category, start, limit.

function callback - A callback function to receive the data from the request.

newFetchCategories

newFetchCategories(callback)

Fetches all categories available to events

Parameters:

function callback - A callback function to receive the data from the request.

newFetchEventDetails

newFetchEventDetails(eventID, callback)

Fetches details of an event

Parameters:

int eventID - The numerical eventID specifying the event.

function callback - A callback function to receive the data from the request.

newFetchEventAttendees

newFetchEventAttendees(eventID, params, callback)

Fetches details of an event

Parameters:

int eventID - The numerical eventID specifying the event.

Array params - The params to filter between the attendees: start and limit.

function callback - A callback function to receive the data from the request.

Class Netlog.Popup

Namespace for the Netlog Popup extension to OpenSocial

Method Summary

object open(url, opt_options, opt_callback)

Netlog Popup component

Method Detail

constructor

open(url, op_options, opt_callback)

Netlog Popup component

Parameters:

String urlA valid URL

object opt_optionsOptional parameters defined in Netlog.Popup.Option

function opt_callbackAn optional callback which will be called after the user closes the popup. The function will be passed one argument: an opensocial.ResponseItem containing a Netlog.Popup.Response object.

Static Class Payment.Popup.Option

All of the options that can be passed on to the Netlog Popup

Field Summary

<static> object HEIGHT

An integer representing the height of the popup window

<static> object SCROLLING

A boolean indicating whether the popup should have scrollbars or not)

<static> object WIDTH

An integer representing the width of the popup window

<static> object URL

The URL of the popup window

Field Detail

HEIGHT

<static> object HEIGHT

An integer representing the height of the popup window

SCROLLING

<static> object SCROLLING

A boolean indicating whether the popup should have scrollbars or not (defaults to true)

WIDTH

<static> object WIDTH

An integer representing the width of the popup window

URL

<static> object URL

The URL of the popup window

Class Netlog.Popup.Response

Used to pass a close event on the popup to the optional callback function of the Netlog.Popup.open function.

Method Summary

object getField(key, opt_params)

Get the data for the response that is associated with the specified key

Method Detail

getField

object getField(key, opt_params)

Get the data for the response that is associated with the specified key

Parameters:

String key - The key to get data for; see the Netlog.Popup.Response.Field class for possible values

Map.<opensocial.DataRequest.DataRequestFields, Object> opt_params - Additional params to pass to the request.

Returns:

object The data

Static Class Netlog.Popup.Response.Field

All of the fields the response can have

Field Summary

<static> object STATE

The state (normaly 'closed')

Field Detail

STATE

<static> object STATE

The state (normaly 'closed')

Class Netlog.Autocomplete

Namespace for the Netlog Autocomplete extension to OpenSocial

Method Summary

object constructor(HTMLElement, options)

Netlog Autocomplete component

object getOption(key, opt_params)

Get the option for this component that is associated with the specified key

Method Detail

constructor

constructor(HTMLElement, options)

Netlog Autocomplete component

Parameters:

HTMLElement element - A HTML input field

Object options - A list of options to customize the autocomplete

getOption

String getOption(key, opt_params)

Get the option for this component that is associated with the specified key

Parameters:

String key - The key to get data for; see the Netlog.Autocomplete.Option class for possible values

Map.<opensocial.DataRequest.DataRequestFields, Object> opt_params - Additional params to pass to the request.

Returns:

object The option

Static Class Netlog.Autocomplete.Option

All of the options the autocomplete component can have

Field Summary

<static> function CALLBACK

A function which will be called with raw results (objects)

<static> HTMLElement RESULTS

An HTMLElement which will be used to store/display the results

<static> function SELECT

A callback function which will be called onclick, when an item is selected

<static> boolean CSS

A boolean used to indicate if you want to use our CSS style for the autocomplete

<static> string URL

URL to fetch the results from

<static> object FIELDS

Mapping for results

<static> string SUBFIELD

An object key specified as string, the key will display the associated value in the results object

<static> HTMLElement DIV

A container div, which will be filled up with the results formed as HTMLElements

<static> string DEFAULTVALUE

A default value to fill up the input field

<static> function CLOSECALL

A callback function, called when the autocomplete is closed

<static> boolean HIDE

When set to true, the results will not be displayed to the user

<static> boolean MULTIFETCH

When true, every keypress will result in a HttpRequest

<static> boolean HIGHLIGHT

Whether or not to highlight parts of the search results

Field Detail

CALLBACK

<static> function CALLBACK

A function which will be called with raw results (objects).

RESULTS

<static> HTMLElement RESULTS

An HTMLElement which will be used to store/display the results.

SELECT

<static> function SELECT

A callback function which will be called onclick, when an item is selected.

CSS

<static> boolean CSS

A boolean used to indicate if you want to use our CSS style for the autocomplete.

URL

<static> string URL

URL to fetch the results from.

FIELDS

<static> object FIELDS

Mapping for results, example: map a server result "thumbnailUrl"
to our default field image { 'thumbnailUrl' : 'image' }
fields available: image, category and name

SUBFIELD

<static> string SUBFIELD

An object key specified as string, the key will display the associated value in the results object.
When specified, the optional field in the result display will be filled with the found value.

DIV

<static> HTMLElement DIV

A container div, which will be filled up with the results formed as HTMLElements.
Only used when using css = true.

DEFAULTVALUE

<static> string DEFAULTVALUE

A default value to fill up the input field.

CLOSECALL

<static> function CLOSECALL

A callback function, called when the autocomplete is closed.
Called when the user clicks the close button in the input field.
Only available when using css=true.

HIDE

<static> boolean HIDE

When set to true, the results will not be displayed to the user.
The component will only send the results to the "callback" function.
Defaults to false

MULTIFETCH

<static> boolean MULTIFETCH

When true, every keypress bigger than 3 chars will result in a HttpRequest. When false, 1 HttpRequest will be made, the results obtained will be filtered.

HIGHLIGHT

<static> boolean HIGHLIGHT

Whether or not to highlight parts of the search results.

Class Netlog.Autocomplete.Friends

Namespace for the Netlog Autocomplete Friends extension to OpenSocial

Method Summary

object constructor(HTMLElement, options)

Netlog Autocomplete Friends component

Method Detail

constructor

object constructor(HTMLElement, options)

Netlog Autocomplete Friends component.
The URL is predefined by Netlog to fetch friend results from our server.
! Used when building an autocomplete feature which searches for the friends of a user.

Parameters:

HTMLElement element - A HTML input field

Object options - Accepts the same options as the Netlog.Autocomplete class

Class Netlog.Album

Namespace for the Netlog Album extension to OpenSocial

Method Summary

<static> newFetchAlbumsRequest(idSpec, opt_params, callback)

Fetch albums belonging to a user (idSpec)

<static> newFetchMediaItemsRequest(idSpec, albumId, opt_params, callback)

Fetch media items belonging to an album

Method Detail

newFetchAlbumsRequest

newFetchAlbumsRequest(idSpec, opt_params, callback)

The first parameter accepts a userID or idSpec (VIEWER or OWNER).
The albums belonging to the specified user will be returned, providing you have access to the information.
The optional parameters allow you to filter the results.
The optional callback will be triggered when a valid request is returned.

Parameters:

string idSpec - A numeric userID or a string (VIEWER or OWNER)

Object opt_params - Accepts following options

function callback - Will be called when a request succeeds

Example:

<script type="text/javascript">
window.onload = function() {
 Netlog.Album.newFetchAlbumsRequest(userId, {}, receiveResults);
};
function receiveResults(response) {
 console.log(response);
}
</script>

Returns:

object An OpenSocial ResponseItem containing an array of albums

Options

ID

array ID

An array of album Ids to fetch (fetch all albums if empty, subject to pagination).

FIRST

integer FIRST

Used in pagination. For example: when a result contains 7 items, and you only want the last 4, you would specify first as 3.

MAX

integer MAX

Used in pagination. For example: when a result contains 7 items, and you only want to display 4 results, you would specify max as 4.

newFetchMediaItemsRequest

newFetchMediaItemsRequest(idSpec, albumId, opt_params, callback)

The first parameter accepts a userID or idSpec (VIEWER or OWNER).
The second parameter is mandatory, specifying the specific id of the album you want to retrieve content from.
The optional parameters allow you to filter the results.
The optional callback will be triggered when a valid request is returned.

Parameters:

string idSpec - A numeric userID or a string (VIEWER or OWNER)

integer albumId - A numeric albumId specifying an existing album.
If a wildcard (*) is provided instead of a numeric value, all media items of all albums will be fetched, respecting pagination if any.

Object opt_params - Accepts following options

function callback - Will be called when a request succeeds

Example:

<script type="text/javascript">
window.onload = function() {
 Netlog.Album.newFetchMediaItemsRequest(userId, albumId, {}, receiveResults);
};
function receiveResults(response) {
 console.log(response);
}
</script>

Returns:

object An OpenSocial ResponseItem containing an array of Media Items belonging to an album.

Options

ID

array ID

An array of media item Ids to fetch (fetch all media items if empty, subject to pagination), belonging to the album.

FIRST

integer first

Used in pagination. For example: when a result contains 7 items, and you only want the last 4, you would specify first as 3.

MAX

integer MAX

Used in pagination. For example: when a result contains 7 items, and you only want to display 4 results, you would specify max as 4.

Class Payment

Namespace for the Netlog Payment extensions to OpenSocial

Method Summary

object constructor(amount, opt_message)

create an instance of a payment

object getField(key, opt_params)

Get the data for the payment that is associated with the specified key

<static> requestPayment(payment, opt_callback, opt_params)

Request the container (Netlog) for a payment

constructor

object constructor(amount, opt_message)

create an instance of a payment

Parameters:

integer amount - The number of credits you want to get from the user

string op_message - Optional message for this payment. The message will be shown to the user when requesting the payment

getField

object getField(key, opt_params)

Get the data for the payment that is associated with the specified key

Parameters:

String key - The key to get data for; see the Payment.Field class for possible values

Map.<opensocial.DataRequest.DataRequestFields, Object> opt_params - Additional params to pass to the request.

Returns:

object The data

requestPayment

<static> object requestPayment(payment, opt_callback, opt_params)

Request the container (Netlog) for a payment

Parameters:

object payment - an instance of a payment

Function opt_callback - The function to call once the request has been processed; This function will be passed one parameter, an opensocial.ResponseItem

object opt_params - Optional parameters that will be send to your payment confirmation page (see the credtis tutorial)

Static Class Payment.Field

All of the fields a payment can have

Field Summary

<static> object AMOUNT

An integer representing the amount of credits associated to the payment

<static> object MESSAGE

A string representing the message associated to the payment

<static> object STATE

State of the payment, specified as a Payment.State

<static> object TOKEN

A string representing a unique token associated to the payment

Field Detail

AMOUNT

<static> object AMOUNT

An integer representing the amount of credits associated to the payment

MESSAGE

<static> object MESSAGE

A string representing the message associated to the payment. This message will be shown to the user when requesting a certain amount of credits.

STATE

<static> object STATE

State of the payment, specified as a Payment.State

TOKEN

<static> object TOKEN

A string representing a unique token associated to the payment

Static Class Payment.State

All of the states a payment can have

Field Summary

<static> object ACCEPTED

The payment has been accepted by the user

<static> object CANCELLED

The payment has been cancelled by the user

<static> object DENIED

The payment has been denied by the user

Field Detail

ACCEPTED

<static> object ACCEPTED

The payment has been accepted by the user

CANCELLED

<static> object CANCELLED

The payment has been cancelled by the user

DENIED

<static> object DENIED

The payment has been denied by the user