Permalink
Browse files

First commit of OHT API Client library for PHP

  • Loading branch information...
0 parents commit 06c49f4dc94d6020468ed624c9d65fc9bed7bae0 Oren yagev committed Jul 20, 2010
0 README
No changes.
@@ -0,0 +1,43 @@
+<?php
+
+$result = array();
+
+$type = (!empty($_POST['type'])) ? $_POST['type'] : NULL ;
+$result['type'] = $type;
+
+switch ($type) {
+ case 'status_change' :
+ $result['project_id'] = (!empty($_POST['project_id'])) ? (int)$_POST['project_id'] : NULL ;
+ $result['word_count'] = (!empty($_POST['word_count'])) ? (int)$_POST['word_count'] : NULL ;
+ $result['source'] = (!empty($_POST['source'])) ? $_POST['source'] : NULL ;
+ $result['target'] = (!empty($_POST['target'])) ? $_POST['target'] : NULL ;
+ $result['credits'] = (!empty($_POST['credits'])) ? (int)$_POST['credits'] : NULL ;
+ $result['project_status'] = (!empty($_POST['project_status'])) ? $_POST['project_status'] : NULL ;
+ $result['estimate_finish'] = (!empty($_POST['estimate_finish'])) ? $_POST['estimate_finish'] : NULL ;
+ $result['translation_ready'] = (!empty($_POST['translation_ready'])) ? (bool)$_POST['translation_ready'] : NULL ;
+ $result['project_url'] = (!empty($_POST['project_url'])) ? $_POST['project_url'] : NULL ;
+ break;
+ case 'translation_submitted':
+ $result['project_id'] = (!empty($_POST['project_id'])) ? (int)$_POST['project_id'] : NULL ;
+ $result['original_content'] = (!empty($_POST['original_content'])) ? base64_decode($_POST['original_content']) : NULL ;
+ $result['translated_content'] = (!empty($_POST['translated_content'])) ? base64_decode($_POST['translated_content']) : NULL ;
+ $result['content_type'] = (!empty($_POST['content_type'])) ? $_POST['content_type'] : NULL ;
+ break;
+
+}
+
+ob_start();
+
+print_r($result);
+
+$ob = ob_get_clean();
+ob_end_clean();
+
+$h = fopen('/tmp/callback','a');
+fwrite($h,"*************\n");
+fwrite($h,date('Y-m-d H:i:s')."\n");
+fwrite($h,$ob);
+fwrite($h,"\n*************\n\n");
+fclose($h);
+
+?>
@@ -0,0 +1,18 @@
+<?php
+ require_once '../lib/OHTAPI.php';
+ try{
+ OHTAPI::config(array(
+ 'account_id'=> 269 , //demo user account
+ 'secret_key' => '5a68561984276108fa42d7cffbbf91a5' , //demo user account
+ true //use sandbox
+ ));
+ $oht = OHTAPI::instance();
+
+ $result = $oht->getAccountDetails();
+
+ var_dump($result);
+ }catch(Exception $e){
+ echo $e;
+ }
+
+?>
@@ -0,0 +1,18 @@
+<?php
+ require_once '../lib/OHTAPI.php';
+ try{
+ OHTAPI::config(array(
+ 'account_id'=> 269 , //demo user account
+ 'secret_key' => '5a68561984276108fa42d7cffbbf91a5' , //demo user account
+ true //use sandbox
+ ));
+ $oht = OHTAPI::instance();
+
+ $result = $oht->getProjectContents(1418);
+
+ var_dump($result);
+ }catch(Exception $e){
+ echo $e;
+ }
+
+?>
@@ -0,0 +1,18 @@
+<?php
+ require_once '../lib/OHTAPI.php';
+ try{
+ OHTAPI::config(array(
+ 'account_id'=> 269 , //demo user account
+ 'secret_key' => '5a68561984276108fa42d7cffbbf91a5' , //demo user account
+ true //use sandbox
+ ));
+ $oht = OHTAPI::instance();
+
+ $result = $oht->getProjectDetails(1418);
+
+ var_dump($result);
+ }catch(Exception $e){
+ echo $e;
+ }
+
+?>
@@ -0,0 +1,31 @@
+<?php
+ require_once '../lib/OHTAPI.php';
+ try{
+ OHTAPI::config(array(
+ 'account_id'=> 269 , //demo user account
+ 'secret_key' => '5a68561984276108fa42d7cffbbf91a5' , //demo user account
+ true //use sandbox
+ ));
+ $oht = OHTAPI::instance();
+
+ $result = $oht->newProject(
+ 'en-us', //from English
+ 'fr-fr', //to French
+ 'A book is a set of printed sheets of paper held together between two covers.
+ The sheets of paper are usually covered with a text:
+ language and illustrations: that is the main point of a printed book.
+ A book can also be a text in a larger collection of texts.
+ This text has some features that do not apply to the collection as a whole.
+ aps written by one author, or it only treats one subject area.
+ Books in this sense can often be understood without knowing the whole collection.',
+ 0, //word count - leave 0 or false to auto-count
+ 'Please be accurate!', //note to the translator (will not be translated)
+ 'http://www.example.com/path/to/callback' //callback url
+ );
+
+ var_dump($result);
+ }catch(Exception $e){
+ echo $e;
+ }
+
+?>
Oops, something went wrong.

0 comments on commit 06c49f4

Please sign in to comment.