Vp user attributes by id: Difference between revisions
Jump to navigation
Jump to search
Basic layout |
m Added warning about failed requests |
||
Line 7: | Line 7: | ||
The user attributes will be returned in the {{sdk event|USER_ATTRIBUTES}} event. See {{sdk method|event_set}}. | The user attributes will be returned in the {{sdk event|USER_ATTRIBUTES}} event. See {{sdk method|event_set}}. | ||
|caveats= | |caveats= | ||
If the request fails then there will be no response from the server (e.g. if the user id doesn't exist). | |||
|examples= | |examples= | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> |
Latest revision as of 23:31, 30 July 2018
Method call snippet
vp_user_attributes_by_id(instance, user_id);
Request user attributes by user ID.
Parameters
These are the parameters that this method requires:
Parameter | Usage |
---|---|
VPInstance instance |
Pointer to the instance this method call is intended for |
int user_id |
User id |
Returns
This method returns a return code integer, which indicates whether the call was successful or errored for any reason:
Return code | Cause |
---|---|
VP_RC_SUCCESS |
Successful call (for methods that have a registered callback, it only means the request has been sent) |
Behavior
The user attributes will be returned in the VP_EVENT_USER_ATTRIBUTES
event. See vp_event_set()
.
Caveats
If the request fails then there will be no response from the server (e.g. if the user id doesn't exist).
Examples
void handle_user_attributes(VPInstance sdk)
{
int user_id;
const char *name;
user_id = vp_int(sdk, VP_USER_ID);
name = vp_string(sdk, VP_USER_NAME);
if (user_id == vp_int(sdk, VP_MY_USER_ID))
{
printf("The name of my owner is \"%s\"\n", name);
}
}
int main(int argc, const char* argv[])
{
//...
vp_event_set(sdk, VP_EVENT_USER_ATTRIBUTES, handle_user_attributes);
vp_user_attributes_by_id(sdk, vp_int(sdk, VP_MY_USER_ID));
//...
}