Method signature
This SDK is deprecated
 For games and applications launched from OK please consider using multiplatform SDK
Method is used to send a notification to a friend from a game via invite/suggest widget.
Notification can be sent only if:
- receiver is a friend of current user;
 - receiver enabled game invites in profile settings.
 
OKSDK.Widgets.suggest(returnUrl, options)Where:
- returnUrl - URL on which user will be redirected after a notification was sent / declined. Optional parameter;
 - options - additional parameters, object:
- autosel - amount of auto selected friends;
 - comment - default notification text;
 - custom_args - additional parameters that are going to be passed to a game if it was launched from a notification;
 - nohead - show OK header in a widget window;
 - state - additional parameters that are going to be passed in method’s result;
 - target - list of user ids that are going to be auto selected;
 - target_only - show only users specified in a target parameter;
 
 
Full parameters description is available here
Return URL message
If returnUrl parameter was specified and options.silent was not user will be redirected to a specified URL.
Method’s result will be passed in an URL as additional GET parameters:
- code - result code:
- OK - invite was successfully sent;
 - CANCELLED - request was cancelled by user;
 - PARAM_SIGNATURE and other - an error occurred while sending an invite. Full error list is available here
 
 - selected - list of user IDs to whom invites were sent;
 - result - method’s result as an object. Contains all other result parameters;
 - error_code - error code;
 - error_msg - error text;
 - sig - request signature.
 
Response example for a successfully sent invite case
?code=OK
&result={"code":"OK","selected":"[1234567890]"}
&selected=[1234567890]
&sig=297a083bc6a3e15*****c08f8ff52cc3
Response example for a cancelled request
?code=CANCELLED
&error_code=12
&error_msg=Operation was cancelled by user
&message=Operation was cancelled by user
&result={"error_code":"12","code":"CANCELLED","error_msg":"Operation was cancelled by user","message":"Operation was cancelled by user"}
&sig=769bab70551*****5551182e5b1e7e22
Response example in case of an error
?code=PARAM_SIGNATURE
&error_code=104
&error_msg=Bad signature
&message=Bad signature
&result={"error_code":"104","code":"PARAM_SIGNATURE","error_msg":"Bad signature ","message":"Bad signature "}
Window postMessage
If returnUrl was not specified then postMessage with method’s result will be sent to a parent window.
Message will contain data field with all the valuable data about method’s result. This data is same as in case of returnUrl specified.
Response example for a successfully sent invite case
{
    "code": "OK",
    "selected": "[1234567890]"
}Response example for a cancelled request
{
    "error_code": "12",
    "code": "CANCELLED",
    "error_msg": "Operation was cancelled by user",
    "message": "Operation was cancelled by user"
}Response example in case of an error
{
    "error_code": "104",
    "code": "PARAM_SIGNATURE",
    "error_msg": "Bad signature ",
    "message": "Bad signature "
}You can add an eventListener which will process such messages:
    window.addEventListener('message', function (widgetMessage) {
        console.log(JSON.stringify(widgetMessage.data));
        // result handling code goes here
    }, false);
    Example usage
OKSDK.Widgets.suggest(
    null,
    {
        "autosel": 3,
        "nohead": false,
        "popup": true
    }
)As a result a dialog will be open where user can select friends to send them a notification:


