Gigya Job Openings

comments.postComment REST

Skip to end of metadata
Go to start of metadata

Description

Post a comment to a specified comments stream.

Request URL


Where <Data_Center> is:
  • us1.gigya.com - For the US data center.
  • eu1.gigya.com - For the European data center.
  • au1.gigya.com - For the Australian data center.
  • ru1.gigya.com - For the Russian data center.
  • cn1.gigya-api.cn - For the Chinese data center.

If you are not sure of your site's data center, see Finding Your Data Center.

Parameters

Notes: If you are posting a review, please notice the extra required Rating & Reviews related parameters. A review is posted to a comments category that is defined with 'Operation mode: Rating & Reviews'. Learn more in the R&R guide.
We also provide an explanation on how to make the comments in your Comments plugin searchable using Search Engine Optimization (SEO) Support.

RequiredNameTypeDescription
categoryIDstringThe identifier of the comments category to which you would like to post the comment.
commentTextstringThe content of the comment to post. The string may be maximum 5000 characters long.
The HTML elements that are allowed are: divbrpspan - always allowed, and  ulliubiem - allowed when RichText is enabled. Other than these exceptions, the text is sanitized and all other HTML elements are removed.
streamIDstringThe identifier of the comments stream to which you would like to post the comment. The default value of this parameter is an empty string.
parentIDstringThe identifier of the parent comment. In case this comment is a reply to another comment, this field is the ID of the comment to which this comment replies. Note: Facebook have changed their policy and no longer support replies to comments. Gigya are exploring methods of keeping this functionality operational, but at present it is not supported.
guestNamestringGuest user name. This field is relevant if the user who posted this comment is a guest user, in which case this field is Required.
guestEmailstringGuest user email. This field is relevant if the user who posted this comment is a guest user, in which case this field is Required.
anonymousBooleanIndicates whether to post this comment anonymously. The default value is 'false'.
UIDstring The unique ID of a logged-in user, with which this method call is associated. This is the UID you receive from Gigya after a successful login of this user. If the user is not a guest (guestName parameter is not defined) this field is Required.
Note: If you are using account linking then the UID would be your site user ID. To learn more about Social Login with account linking (best practice), please refer to the Login Implementation guide in the Developer's Guide.
cidstring
A string of maximum 100 characters length. The CID sets categories for transactions that can be used later for filtering reports generated by Gigya in the "Context ID" combo box. The CID allows you to associate the report information with your own internal data. For example, to identify a specific widget or page on your site/application. You should not define more than 100 different context IDs.
tagsarray

This parameter is a strings array representing a list of tags, e.g.: ["tag_a","tag_b"]. Each tag in the array is assigned to the posted comment. Tags can be used to filter comments when calling comments.getComments, to get only comments that match the tag. The number of tags is restricted to 15 tags per comment.

Note: the tags parameter officially supports alphanumeric characters only. Entering non-alphanumeric characters may cause the method to fail. Any individual tag must not contain more than 100 characters.

photoURLstringA URL of a photo to be used for a guest commenter. 
isModeratorBooleanIndicates whether the comment has been posted by a moderator. The default value is "false". This parameter can be set only by moderators.
actionAttributesJSON objectIn Gamification your users receive points for actions they perform on your site, in this case posting a comment grants the user points. Action Attributes may be used to annotate actions with additional information, such as the section of the web site that generated the action. If you set here the actionAttributes, each time a user posts a comment, the action also receives an attribute, for example "tv-show":"glee", which can mean that the action was performed on the "Glee" page of the site. 
actionAttributes contain a JSON object comprised of a series of attribute keys (categories) with associated values. You can also use a generic "tags" key.

No more than three values can be given, they can be with a single key or each have their own key.

For more information see Variants and Action Attributes. Action attributes are later used to filter GM Plugins by a certain attribute.
Example:  {"<attribute key1>": ["<attribute value1>", "<attribute value2>"],  "<attribute key2>": "<attribute value3>" }

 
streamTagsarray or stringEither a comma separated list or a JSON array of tags (strings) that should be associated with the stream. Note: the stream tags will be added to the stream only if this method creates a new stream.
mediaItemsarrayAn array of URLs of media items to attach to the comment. Currently media items are limited to 3 per comment. If the number of media items exceeds this limit, only the first 3 will be posted. This parameter is only accepted if clientSettings.enableMediaItems is set to true for the category via comments.setCategoryInfo.
taggedUsersarrayAn array of users (UIDs) tagged in the comment body. The taggedUsers array replaces the users that are tagged in the comment. The comment body should have special markup elements that refer to the index of the tagged user in the array. Nulls are allowed members of the array.

Currently tagged users are limited to 10 per comment. If the number of tagged users exceeds this limit, only the first 10 will be posted. This parameter is only accepted if clientSettings.enableUserTagging is set to true for the category via comments.setCategoryInfo.

Rating & Reviews related Parameters:
The following fields are relevant only if you are posting a Rating&Review
commentTitlestringA title for the comment. The title may be maximum 250 characters long.
* This parameter is Required given the following conditions:
  • If you are posting to a categoryID that is defined with 'Operation mode: Rating & Reviews'.
  • And, in the Comments Settings of the relevant categoryID, 'Enable Comment Titles:' is set to 'Enable'.
  • And, the parentID parameter is not specified (i.e. you are posting a Review and not a comment to a review).
   In any other case the commentTitle is irrelevant and is ignored.
ratingsJSON
Object
An object that defines user ratings for this stream.
The object structure is: {'_overall': ratingValue}, where the ratingValue is an integer between 1-5.
* This parameter is Required given the following conditions:
  • If you are posting to a categoryID that is defined with 'Operation mode: Rating & Reviews'.
  • And, in the Comments Settings of the relevant categoryID, 'Enable Ratings:' is set to 'Enable'.
  • And, the parentID parameter is not specified (i.e. you are posting a Review and not a comment to a review).

   In any other case the ratings is irrelevant and is ignored.

Note: Rating a stream is permitted only for a logged-in user, which hasn't rated this stream before (each user may rate each stream only once). This method will return an error to a forbidden rating attempt.

Sharing related Parameters:
The following parameters are relevant if you wish to share the comment to social networks
userActionUserAction JSON
 
The user action to publish. The UserAction represented as a JSON string. See below the UserAction JSON representation.
Notes:
The UserAction JSON is equivalent to the UserAction object in the Web SDK. See further usage details there. Please remove empty values from the JSON.
UserActionUserAction JSONIt is possible to specify different content to publish for each social network. For this purpose, the method supports a set of parameters with the same name format: (i.e. facebook, twitter, yahoo, etc.) followed by "UserAction". For example: twitterUserAction - specifies the content to be used specifically when publishing to Twitter.
Each of these parameters accepts a UserAction JSON (same format as the userAction parameter. Each of these optional parameters if specified will override the userAction parameter when posting to that provider. In other words, the userAction parameter (see above) specifies the default content to be used for all social networks and UserAction specifies the content to be used for the specific network.
enabledProvidersstring
A comma-delimited list of provider names to include in the method execution. This parameter gives the possibility to apply this method only to a subset of providers of your choice. If you do not set this parameter, by default all the providers are enabled (i.e., the method applies to all connected providers).
For example, if you would like the method to apply only to Twitter, define: enabledProviders: "twitter".
Valid provider names include:
'facebook', 'twitter', 'yahoo''googleplus', 'linkedin'.
.
disabledProvidersstring
A comma-delimited list of provider names to exclude in the method execution. This parameter gives the possibility to specify providers to which you do not want this method to apply. If you do not set this parameter, by default, no provider is disabled (i.e., the method applies to all connected providers).
For example, if you would like the method to apply to all providers except Twitter, define: disabledProviders: "twitter".
Valid provider names include:
'facebook', 'twitter', 'yahoo''googleplus', 'linkedin'.
.
shortURLsstringUsing this parameter you may determine whether to use Gigya's URL shortening service for URLs, which are published through this method. The optional values for this parameter are:
  • 'always' (default) - always shorten URLs.
  • 'whenRequired' - shorten URLs when needed, based on social network requirements.
  • 'never' - never shorten URLs.
When Gigya's URL shortening service is active, Gigya tracks all the traffic coming from the distributed URLs. In such cases, 'Referred Traffic' reports will be available to you.
format string Determines the format of the response. The options are:
  • json (default)
  • jsonp - if the format is jsonp then you are required to define a callback method (see parameter below).
callback string This parameter is required only when the format parameter is set to jsonp (see above). In such cases this parameter should define the name of the callback method to be called in the response, along with the jsonp response data.
context string/JSON This parameter may be used to pass data through the current method and return it, unchanged, within the response.
dontHandleScreenSet Boolean This parameter may be used in order to suppress the showing of screen-sets as a result of API calls. Default is false.
httpStatusCodes Boolean The default value of this parameter is false, which means that the HTTP status code in Gigya's response is always 200 (OK), even if an error occurs. The error code and message is given within the response data (see below). If this parameter is set to true, the HTTP status code in Gigya's response would reflect an error, if one occurred.

Authorization Parameters

Each REST API request must contain identification and authorization parameters.

Some REST APIs may function without these authorization parameters, however, when that occurs, these calls are treated as client-side calls and all client-side rate limits will apply. In order to not reach client-side IP rate limits that may impact your implementation when using server-to-server REST calls, it is Recommended Best Practice to always sign the request or use a secret. A non-exhaustive list of REST APIs that this may apply to are as follows:

  • accounts.login
  • socialize.login
  • accounts.notifyLogin
  • socialize.notifyLogin
  • accounts.finalizeRegistration
  • accounts.linkAccounts

Please refer to the Authorization Parameters section for details. 

Sample Requests

 

 

Response Data

FieldTypeDescription
 
errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.
errorMessage string A short textual description of an error, associated with the errorCode, for logging purposes. This field will appear in the response only in case of an error.
errorDetails string This field will appear in the response only in case of an error and will contain the exception info, if available.
fullEventName string The full name of the event that triggered the response. This is an internally used parameter that is not always returned and should not be relied upon by your implementation.
callId string Unique identifier of the transaction, for debugging purposes.
time string The time of the response represented in ISO 8601 format, i.e., yyyy-mm-dd-Thh:MM:ss.SSSZ or
statusCode integer The HTTP response code of the operation. Code '200' indicates success.
This property is deprecated and only returned for backward compatibility.
statusReason string A brief explanation of the status code.
This property is deprecated and only returned for backward compatibility.

 

commentComment objectThe posted comment. The comment is returned only if it has been approved.

A field that does not contain data will not appear in the response.

 

Response Example

{
        "comment": {
            "ID": "7d8431995e9d4088bb77562eea1fa430",
            "threadID": "",
            "commentText": "Love this!",
            "sender": {
                "photoURL": "http://a323.yahoofs.com/coreid/4a0fd68gGPBvUEtodfm",
                "profileURL": "http://pulse.yahoo.com/_DBFQRAMCLDNXZQ",
                "loginProvider": "Yahoo",
                "name": "David"
            },
            "flagCount": 0,
            "timestamp": 1308589165362,
            "threadTimestamp": 1308589165362,
            "status":"published"
        },
        "statusCode": 200,
        "errorCode": 0,
        "statusReason": "OK",
        "callId": "ddb3f8e144c84cb5b1bc5f010bddab2b",
        "time": "2015-03-22T11:42:25.943Z"
}