-
Notifications
You must be signed in to change notification settings - Fork 158
Dev API
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.
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.
Provides information about current profile.
This endpoint doesn't have any arguments.
Provides information about another profile.
Possible GET/POST arguments:
-
id
- profile id to get info for
Get list of friends.
Possible GET/POST arguments:
-
id
- profile id to get friends list for
Market functions.
Arguments are the same as for service
endpoint but without module
argument.
Call service functions.
Possible GET/POST arguments:
-
module
- module name. List of all installed modules names can be foundsys_modules
table,name
field. -
method
- module service method. Modules service methods always look like thisserviceGetSmth
in the code, but in this argument it must be specified asget_smth
. -
params
- method parameters array. It can be PHP serialised array or as usual query array, specified asparams []=123¶ms[]=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
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"
}
IMPORTANT NOTE: documentation was moved here - https://una.io/wiki/Introduction