text.get
Get a stored text. Returns a text object.
Request Parameters
| collection_id | int (required) |
Collection id where text is stored.
| text_id | int (required) |
Id for text to get.
| ext_text_id | String |
Get a text based on the external text id. Parameter text_id always has priority over ext_text_id.
Response Parameters
| text_id | int |
Id for the text.
| collection_id | int |
Id where text is stored.
| headline | String |
Text headline.
| url | String |
URL where text is published.
| publish_date | String |
Date when the text was published in ISO 8601 format. (YYYY-MM-DDTHH:mm:ssZ)
| ext_text_id | String |
The external text id for the text.
Code Examples
JSON
//Request
{
"method":"text.get",
"params":{
"collection_id":607,
"text_id":1
"ext_text_id":98563154
},
"id":0
}
//Response
{
"id":0,
"result":{
"headline":"My headline",
"url":"",
"collection_id":607,
"text_id":1,
"ext_text_id":"98563154"
}
}
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 know the id of the text and collection it is in
SaploText text = new SaploText();
text.setCollection(collection);
text.setId(myTextId);
textMgr.get(text);
// Your text object's attributes get populated by the API
System.out.println(text.getHeadline());
System.out.println(text.getBody());
System.out.println(text.getUrl().toString());
// etc
PHP
$client = new SaploAPI("YOUR API KEY", "YOUR SECRET KEY");
$params = array(
"collection_id" => 1,
"text_id" => 31
);
try {
$result = $client->text->get($params);
} catch(SaploException $e) {
echo '(' . $e->getCode() . ') ' . $e->getMessage();
}
var_dump($result);
Python
client = SaploJSONClient("YOUR API KEY", "YOUR SECRET KEY")
text = client.text.get(
collection_id=678,
text_id=1
)
print "Retrieved text:", text
Matlab
params.text_id = 1;
params.collection_id = 2131;
response = saploRequest('text.get', params)