-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcategories.php
More file actions
26 lines (23 loc) · 944 Bytes
/
categories.php
File metadata and controls
26 lines (23 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
* Example code to call Analytics API to get a document's (located at given URL) category.
**/
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use rosette\api\Api;
use rosette\api\DocumentParameters;
use rosette\api\RosetteException;
$options = getopt('', array('key:', 'url::'));
if (!isset($options['key'])) {
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
exit();
}
$categories_text_data = "If you are a fan of the British television series Downton Abbey and you are planning to be in New York anytime before April 2nd, there is a perfect stop for you while in town.";
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$params->set('content', $categories_text_data);
try {
$result = $api->categories($params);
var_dump($result);
} catch (RosetteException $e) {
error_log($e);
}