Commits

Maru Newby  committed 5061e43

Updated php wrapper to be v2 compliant.

  • Participants
  • Parent commits e6c6cee

Comments (0)

Files changed (2)

File php/Repustate.php

     public $apiKey;
     public $version;
 
-    public function __construct($apiKey, $version='v1')
+    public function __construct($apiKey, $version='v2')
     {
         $this->apiKey = $apiKey;
         $this->version = $version;
             'text' => $text,
             'url' => $url,
         );
-        $useHttpGet = ($text == null);
+        $useHttpGet = FALSE;
         return $this->callApi($apiFunction, $args, $responseType, $useHttpGet);
     }
 
     }
 
     //
+    // Convert english date indicators like "today", "tomorrow", "next week"
+    // into date strings like 2011-01-12.
+    //
+    public function dateExtraction($text=null, $relativeDate=null,
+                                   $responseType='json')
+    {
+        if (is_array($text))
+        {
+            extract($text, EXTR_IF_EXISTS);
+            if (is_array($text))
+            {
+                $text = null;
+            }
+        }
+        $args = array(
+            'text' => $text,
+            'relative_date' => $relativeDate,
+        );
+        return $this->callApi('extract-dates', $args, $responseType);
+    }
+
+    //
     // Given a list of images and titles, generate a simple powerpoint
     // presentation.
     //

File php/RepustateTest.php

         $this->checkCall('ngrams', $args);
     }
 
-    /* public function testPowerpoint() */
-    /* { */
-    /*     $args = array( */
-    /*         'reportTitle' => 'Test Report', */
-    /*         'author' => 'Martin Ostrovsky', */
-    /*         'images' => array('test.gif'), */
-    /*         'titles' => array('A test title'), */
-    /*     ); */
-    /*     $accessor = $this->getAccessor(); */
-    /*     $result = $accessor->powerpoint($args); */
-    /* } */
+    public function testDateExtraction()
+    {
+        $this->checkCall('dateExtraction', array('text' => 'iPad'));
+    }
+
+    public function testPowerpoint()
+    {
+        $args = array(
+            'reportTitle' => 'Test Report',
+            'author' => 'Martin Ostrovsky',
+            'images' => array('repustate.gif'),
+            'titles' => array('A test title'),
+        );
+        $accessor = $this->getAccessor();
+        $result = $accessor->powerpoint($args);
+        $this->assertNotEmpty($result, 'Result should not be empty');
+    }
 }
 
 ?>