group.addText
Add a text to a group. Returns a list of all texts in the group.
Request Parameters
| group_id | int (required) |
The group id to which the text will be added. Group and Text must use the same language.
| collection_id | int (required) |
The collection id where the text is stored.
| text_id | int (required) |
Id of text to add to the context.
| ext_text_id | String |
If you have provided your own ext_text_id when adding texts to a collection this can be used. Though text_id always has priority over ext_text_id.
Response Parameters
| success | boolean |
Indicates whether the request was successful.
Code Examples
JSON
//Request
{
"method":"group.addText",
"params":{
"group_id":744,
"collection_id":607,
"text_id":3
},
"id":0
}
//Response
{
"id":0,
"result":{
"success": true
}
Java
// You need to have a ready-to-use client to use the other methods
SaploClient client = new SaploClient("YOUR_API_KEY", "YOUR_SECRET_KEY");
// Create a SaploGroupManager to work with groups
SaploGroupManager groupMgr = new SaploGroupManager(client);
// Assuming you know the ID of the group you want to add text to
SaploGroup group = new SaploGroup();
group.setId(groupId);
// Assuming you already have a text object saved in the API,
// with id and SaploCollection elements
// Add the text to the group
boolean isOk = groupMgr.addText(group, text);
// Print the result
if(isOk)
System.out.println("Text " + text.getId()
+ " successfully added to group " + group.getId());
else
System.out.println("The text was not added! Failure");
PHP
$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");
//Run method
$params = array(
'group_id' => 21,
'collection_id' => 606,
'text_id' => 11
);
try {
$result = $client->group->add_text($params);
} catch(SaploException $e) {
echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
var_dump($result);
Python
client = SaploJSONClient("YOUR API KEY", "YOUR SECRET KEY")
text_added = client.group.add_text(
group_id=787,
collection_id=678,
text_id=1
)
print "Succesfully added text to group."
Matlab
params.group_id = 415;
params.collection_id = 2131;
params.text_id = 2;
response = saploRequest('group.addText', params)