text.update

Update an existing text.

Request Parameters

collection_idint (required)
Collection id where text is stored.
text_idint (required)
Id for text to update.
headlineString
Text headline. Maximum 250 chars.
bodyString
The body text. Maximum 100 000 chars.
publish_dateString

Date when the text was published in ISO 8601 format. (YYYY-MM-DDTHH:mm:ssZ)

urlString
Publish URL for the text.
authorsString
Authors who wrote this text.
ext_text_idString

Update a text based on the external text id. The param text_id always has priority over ext_text_id so if they don't refer to the same text the param text_id is used.

If you want to update the ext_text_id you need to provide the text_id
forceboolean (default: false)

Set to true to force a text into provided collection. Used in cases when your text is rejected but you know the text language matches the collection language.

Warning! If your text doesn't match your collection language it strongly effects the result.

Response Parameters

text_idint
The id for the text.
collection_idint
The collection id for where the text is stored.
headlineString
Text headline.
urlString
Publish URL for the text.
ext_text_idString

The external text id.

Code Examples

JSON

//Request
{
 "method":"text.update", 
 "params":{
    "headline":"My headline",
    "body":"Updated text.", 
    "collection_id":607, 
    "text_id":1,
    "ext_text_id":"ASX-21"
    },
 "id":0
}

//Response
{
 "id":0,
 "result":{
    "headline":"My headline",
    "url":"", 
    "collection_id":607,
    "text_id":1,
    "ext_text_id":"ASX-21"
 }
}

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 SaploTextManager to work with texts
SaploTextManager textMgr = new SaploTextManager(client);

// Assuming you have the text you want to update, 
// with a valid collection element, and textId
text.setBody("I have just updated my text body!");
text.setHeadline("An updated article!");

// To apply the changes, call the manager's "update" method
textMgr.update(text);

PHP


$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");

$params = array(
    "collection_id" => 1,
    "text_id" => 31,
    "body" => "Updating the text to this."
);

try {
    $result = $client->text->update($params);
} catch(SaploException $e) {
    echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
 
var_dump($result);

Python


client = SaploJSONClient("YOUR API KEY", "YOUR SECRET KEY")

updated_text = client.text.update(
            collection_id=678,
            text_id=2,
            headline="New Headline"
            )

print "Updated text:", updated_text

Matlab

params.headline = 'Sweden a beautiful country!';
params.collection_id = 2131;
params.text_id = 1;

response = saploRequest('text.update', params)