get() public method

Make a GET call to a DataSift API endpoint.
public get ( string $endpoint, array $params = [], $headers = [] ) : array
$endpoint string The endpoint of the API call.
$params array The parameters to be passed along with the request.
return array The response from the server.
コード例 #1
0
ファイル: Account.php プロジェクト: datasift/datasift-php
 /**
  * Returns the user agent this library should use for all API calls.
  *
  * @return string
  */
 public function usage($start = false, $end = false, $period = null)
 {
     $params = array();
     if ($start) {
         $params['start'] = $start;
     }
     if ($end) {
         $params['end'] = $end;
     }
     if (isset($period)) {
         $params['period'] = $period;
     }
     return $this->_user->get('account/usage', $params);
 }
コード例 #2
0
ファイル: Pylon.php プロジェクト: datasift/datasift-php
 /**
  * Returns a list of sample interactions (super-public)
  *
  * @param Datasift_User $user The Datasift user object
  * @param string $id The id of the existing pylon
  * @param string $filter additional CSDL filter
  * @param int $start the start time of the pylon
  * @param int $end the end time of the pylon
  * @param int $count optional value to set the count
  *
  * @throws DataSift_Exception_InvalidData
  *
  * @return array Response from the sample endpoint
  */
 public function sample($filter = false, $start = false, $end = false, $count = false, $id = false)
 {
     if ($id) {
         $this->_id = $id;
     }
     if (strlen($this->_id) == 0) {
         throw new DataSift_Exception_InvalidData('Unable to retrieve pylon sample without an ID');
     }
     $params = array('id' => $this->_id);
     if ($start) {
         $params['start'] = $start;
     }
     if ($end) {
         $params['end'] = $end;
     }
     if ($count) {
         $params['count'] = $count;
     }
     if ($filter) {
         $params['filter'] = $filter;
         return $this->_user->post('pylon/sample', $params);
     } else {
         return $this->_user->get('pylon/sample', $params);
     }
 }