Ejemplo n.º 1
0
 public function __construct($url, $name)
 {
     /*
     @todo Throw exception for invalid names.
     Diffbot HQ will provide regex for invalid chars in API names. Once
     done, modify this case to throw exceptions for invalid ones, and write
     test cases.
     
     Note that all API names with ? and / in their name currently fail to
     execute in the Diffbot test runner, so it's questionable whether they're
     even supposed to be supported.
     */
     parent::__construct($url);
     $this->apiUrl .= '/' . trim($name);
 }
Ejemplo n.º 2
0
 /**
  * If you pass in `true`, you get back a SearchInfo object related to the
  * last call. Keep in mind that passing in true before calling a default
  * call() will implicitly call the call(), and then get the SearchInfo.
  *
  * So:
  *
  * $searchApi->call() // gets entities
  * $searchApi->call(true) // gets SearchInfo about the executed query
  *
  * @todo: remove error avoidance when issue 12 is fixed: https://github.com/Swader/diffbot-php-client/issues/12
  * @param bool $info
  * @return \Swader\Diffbot\Entity\EntityIterator|SearchInfo
  */
 public function call($info = false)
 {
     if (!$info) {
         $ei = parent::call();
         set_error_handler(function () {
             /* ignore errors */
         });
         $arr = $ei->getResponse()->json(['big_int_strings' => true]);
         restore_error_handler();
         unset($arr['request']);
         unset($arr['objects']);
         $this->info = new SearchInfo($arr);
         return $ei;
     }
     if ($info && !$this->info) {
         $this->call();
     }
     return $this->info;
 }
Ejemplo n.º 3
0
 /**
  * If you pass in `true`, you get back a SearchInfo object related to the
  * last call. Keep in mind that passing in true before calling a default
  * call() will implicitly call the call(), and then get the SearchInfo.
  *
  * So:
  *
  * $searchApi->call() // gets entities
  * $searchApi->call(true) // gets SearchInfo about the executed query
  *
  * @todo: remove error avoidance when issue 12 is fixed: https://github.com/Swader/diffbot-php-client/issues/12
  * @param bool $info
  * @return EntityIterator|SearchInfo
  */
 public function call($info = false)
 {
     if (!$info) {
         $ei = parent::call();
         set_error_handler(function () {
             /* ignore errors */
         });
         $arr = json_decode((string) $ei->getResponse()->getBody(), true, 512, 1);
         restore_error_handler();
         unset($arr['request']);
         unset($arr['objects']);
         $this->info = new SearchInfo($arr);
         return $ei;
     }
     if ($info && !$this->info) {
         $this->call();
     }
     return $this->info;
 }