33 $this->
setUrl(
"https://api.ithenticate.com/rpc");
36 $this->
setSid($this->login());
44 if (property_exists($this,
'url')) {
54 if (property_exists($this,
'username')) {
55 $this->username = $username;
64 if (property_exists($this,
'password')) {
65 $this->password = $password;
74 if (property_exists($this,
"sid")) {
84 if (property_exists($this,
'url')) {
94 if (property_exists($this,
'username')) {
95 return $this->username;
104 if (property_exists($this,
'password')) {
105 return $this->password;
114 if (property_exists($this,
'sid')) {
124 private function login()
132 $response = $client->send(
new Request(
'login', array(
new Value($args,
"struct"))));
133 $response = json_decode(json_encode($response),
true);
134 if (isset($response[
'val'][
'me'][
'struct'][
'sid'][
'me'][
'string'])) {
135 $sid = $response[
'val'][
'me'][
'struct'][
'sid'][
'me'][
'string'];
153 public function submitDocument($essay_title, $author_firstname, $author_lastname, $filename, $document_content, $folder_number)
156 $uploads_array = array(
159 'title' =>
new Value($essay_title),
160 'author_first' =>
new Value($author_firstname),
161 'author_last' =>
new Value($author_lastname),
162 'filename' =>
new Value($filename),
163 'upload' =>
new Value($document_content,
'base64'),
170 'folder' =>
new Value($folder_number),
171 'submit_to' =>
new Value(1),
172 'uploads' =>
new Value($uploads_array,
'array'),
175 $response = $client->send(
new Request(
'document.add', array(
new Value($args,
"struct"))));
176 $response = json_decode(json_encode($response),
true);
177 if (isset($response[
'val'][
'me'][
'struct'][
'uploaded'][
'me'][
'array'][0][
'me'][
'struct'][
'id'][
'me'][
'int'])) {
178 $document_id = $response[
'val'][
'me'][
'struct'][
'uploaded'][
'me'][
'array'][0][
'me'][
'struct'][
'id'][
'me'][
'int'];
179 if ($document_id !=
null) {
194 'name' =>
new Value($group_name),
197 $response = $client->send(
new Request(
'group.add', array(
new Value($args,
"struct"))));
198 $response = json_decode(json_encode($response),
true);
199 if (isset($response[
'val'][
'me'][
'struct'][
'id'][
'me'][
'int'])) {
200 return $response[
'val'][
'me'][
'struct'][
'id'][
'me'][
'int'];
205 public function createFolder($folder_name, $folder_description, $group_id, $exclude_quotes)
210 'folder_group' =>
new Value($group_id),
211 'name' =>
new Value($folder_name),
212 'description' =>
new Value($folder_description),
213 'exclude_quotes' =>
new Value($exclude_quotes),
216 $response = $client->send(
new Request(
'folder.add', array(
new Value($args,
"struct"))));
217 $response = json_decode(json_encode($response),
true);
218 if (isset($response[
'val'][
'me'][
'struct'][
'id'][
'me'][
'int'])) {
219 return $response[
'val'][
'me'][
'struct'][
'id'][
'me'][
'int'];
231 $response = $client->send(
new Request(
'group.list', array(
new Value($args,
"struct"))));
232 $response = json_decode(json_encode($response),
true);
233 if (isset($response[
'val'][
'me'][
'struct'][
'groups'][
'me'][
'array'])) {
234 return array_combine(
235 array_map(
function($o) {
236 return $o[
'me'][
'struct'][
'id'][
'me'][
'int'];
237 }, $response[
'val'][
'me'][
'struct'][
'groups'][
'me'][
'array']),
238 array_map(
function($o) {
239 return $o[
'me'][
'struct'][
'name'][
'me'][
'string'];
240 }, $response[
'val'][
'me'][
'struct'][
'groups'][
'me'][
'array'])
252 'id' =>
new Value($document_id),
255 $response = $client->send(
new Request(
'document.get', array(
new Value($args,
"struct"))));
256 $response = json_decode(json_encode($response),
true);
257 if (isset($response[
'val'][
'me'][
'struct'][
'documents'][
'me'][
'array'][0][
'me'][
'struct'][
'is_pending'][
'me'][
'int'])) {
258 $state = $response[
'val'][
'me'][
'struct'][
'documents'][
'me'][
'array'][0][
'me'][
'struct'][
'is_pending'][
'me'][
'int'];
259 if ($state !==
null) {
260 $is_pending[
'is_pending'] = $state;
276 'id' =>
new Value($document_id),
279 $response = $client->send(
new Request(
'document.get', array(
new Value($args,
"struct"))));
280 $response = json_decode(json_encode($response),
true);
281 if (isset($response[
'val'][
'me'][
'struct'][
'documents'][
'me'][
'array'][0][
'me'][
'struct'][
'parts'][
'me'][
'array'][0][
'me'][
'struct'][
'id'][
'me'][
'int'])) {
282 $report_id = $response[
'val'][
'me'][
'struct'][
'documents'][
'me'][
'array'][0][
'me'][
'struct'][
'parts'][
'me'][
'array'][0][
'me'][
'struct'][
'id'][
'me'][
'int'];
283 if ($report_id !=
null) {
298 'id' =>
new Value($report_id),
299 'exclude_biblio' =>
new Value($exclude_biblio),
300 'exclude_quotes' =>
new Value($exclude_quotes),
301 'exclude_small_matches' =>
new Value($exclude_small_matches),
304 $response = $client->send(
new Request(
'report.get', array(
new Value($args,
"struct"))));
305 $response = json_decode(json_encode($response),
true);
306 if (isset($response[
'val'][
'me'][
'struct'][
'view_only_url'][
'me'][
'string'])) {
307 $report_url = $response[
'val'][
'me'][
'struct'][
'view_only_url'][
'me'][
'string'];
308 if ($report_url !=
null) {