Skip to content
Alex Trofimov edited this page May 31, 2017 · 27 revisions

UNA provides API access to the certain functionality.
API is a part of OAuth2 module, so this module must be installed to make API calls. After user is logged or joined in via OAuth2, API calls can be performed.

Scopes

There are several scopes which allows access to the certain endpoints:

  • basic - provides acces to me, user, friends endpoints and usually used to join user to another site via OAuth2 login/join.
  • market - provides acceess to me, market endpoints and usually used to get access to the market via UNA Studio.
  • service - provides access to service endpoint which can be used to call service methods for different purposes. This endpoint provides access to direct calls of service function and can not be considered as safe.

When key&secret pair is generated by default basic scope is assigned, there is no way to change it via interface, so for more advanced market and service scopes it should be edited directly in the database in bx_oauth_clients table, scope field.

Endpoints

me

Provides information about current profile.

This endpoint doesn't have any arguments.

user

Provides information about another profile.

Possible GET/POST arguments:

  • id - profile id to get info for

friends

Get list of friends.

Possible GET/POST arguments:

  • id - profile id to get friends list for

market

Market functions.

Arguments are the same as for service endpoint but without module argument.

service

Call service functions.

Possible GET/POST arguments:

  • module - module name. List of all installed modules names can be found sys_modules table, name field.
  • method - module service method. Modules service methods always look like this serviceGetSmth in the code, but in this argument it must be specified as get_smth.
  • params - method parameters array. It can be PHP serialised array or as usual query array, specified as params []=123&params[]=abc.
  • class - class name service function belongs to, in the case of main module class (PrefixSuffixModule) - this argument can be omitted.

Output for service calls is always JSON array with the following keys:

  • module - module name
  • method - method name
  • data - method output

Sample usage

There is sample API call to me endpoint, access token given in OAuth2 login should be used.

curl http://example.com/path-to-una/m/oauth2/api/me  -H "Authorization: Bearer 9802c4a34e1535d8c3b721604ee0e7fb04116c49"

Output is always in JSON format, in this case it should look like this:

{  
    "id":"123",
    "type":"bx_organizations",
    "email":"test@example.com",
    "role":"1",
    "name":"Test",
    "profile_display_name":"Test",
    "profile_link":"http:\/\/example.com\/path-to-una\/page\/view-organization-profile?id=12",
    "picture":"http:\/\/example.com\/path-to-una\/image_transcoder.php?o=bx_organizations_picture&h=36&dpx=1&t=1496247306"
}
Clone this wiki locally