DataSift_Pylon::sample PHP Method

sample() public method

Returns a list of sample interactions (super-public)
public sample ( string $filter = false, integer $start = false, integer $end = false, integer $count = false, string $id = false ) : array
$filter string additional CSDL filter
$start integer the start time of the pylon
$end integer the end time of the pylon
$count integer optional value to set the count
$id string The id of the existing pylon
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);
        }
    }

Usage Example

Example #1
0
 public function testSampleNoId()
 {
     $pylon = new DataSift_Pylon($this->user, array('id' => ''));
     $this->setExpectedException('DataSift_Exception_InvalidData');
     $filter = '(fb.content any "coffee" OR fb.hashtags in "tea") AND fb.language in "en"';
     $start = 1445209200;
     $end = 1445274000;
     $count = 10;
     $pylon->sample($filter, $start, $end, $count);
 }
All Usage Examples Of DataSift_Pylon::sample