Social Publish

This module uses the access token set using the Set Token API from the Social Graph module.

So, it’s mandatory to call the “Set Token” API before calling any of the Social Publish APIs.

API: Post events/messages on the social media platform

URL: {BASE_URL}/app/<APP_ID>/social/publish/<MODE>/<USER_ID>/post

Request Method: HTTP POST

Parameter Mandatory Type Description
APP_ID Yes Alpha-numeric The application ID issued by the Playblazer platform when the app was created
secret_key Yes Alpha-numeric The secret key issued by the Playblazer platform when the app was created
MODE Yes String The mode for user ID interpretation
USER_ID Yes String The user ID who wants to post the message.
to:mode Yes String The mode of the target/recipient user
to:id Yes Alpha-numeric The user id of the target/recipient user
template No String

The template of the post - one of:

  • single-line
  • pic-description

More templates will be added in the future.

message Yes String The message that should be posted. This is the basic element that will be posted and is mandatory for every template.
picture No String The URL of the image to be posted in the “pic-description” template.
description No String The description of the picture to be posted in the “pic-description” template.
fmt No String One of (json | xml) - the format of output

If successful, the output will contain status=ok state - of course, in the format that is specified in the API call; otherwise, status=error and error details encoded as explained earlier.

Any social publish API call initiated after the expiry of the token will generate an error.

Example

Note

Sensitive information is masked out in the following examples.

1. Successful call - with single-line message template:

URL Call:

curl -X POST \
    -F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
    -F "template=single-line" \
    -F "message=Test Message from Playblazer" \
    -F "to:mode=fb" \
    -F "to:id=xxxxxxxxxx" \
    "http://api.playblazer.com/v1/app/1/social/publish/fb/kunalg/post"

Output:

{
    "status": "ok",
    "id": "xxxxxxxxxxxxxxx_413543792056116"
}

2. Error - when access token has expired:

URL Call:

curl -X POST \
    -F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
    -F "template=single-line" \
    -F "message=Test Message from Playblazer" \
    -F "to:mode=fb" \
    -F "to:id=xxxxxxxxxx" \
    "http://api.playblazer.com/v1/app/1/social/publish/fb/kunalg/post"

Output:

{
    "status": "error",
    "error": {
        "message": "Token Expired",
        "code": -20001,
        "code_str": "E_TOKEN_EXPIRED"
    }
}