// Include the configuration - put your username and API key in this file require dirname(__FILE__) . '/../../config.php'; // Authenticate echo "Creating user...\n"; $user = new DataSift_User(USERNAME, API_KEY, false); $csdl = '(fb.content any "coffee, tea" OR fb.hashtags in "tea") AND fb.language in "en"'; //Validate the CSDL $validate = DataSift_Pylon::validate($user, $csdl); echo "Definition has been successfully validated, DPUs: {$validate['dpu']} created at: {$validate['created_at']} \n\n"; //Create the PYLON object $pylon_name = "My pylon test"; $pylon = new DataSift_Pylon($user); $pylon->setName($pylon_name); //Add CSDL to the PYLON $pylon->setCsdl($csdl); $pylon->compile(); //Start the pylon $pylon->start(); //Stop after 10 seconds sleep(10); //Compile some new CSDL $pylon->setCsdl('(fb.content any "coffee, tea, flour" OR fb.hashtags in "tea") AND fb.language in "en"'); $pylon->compile(); //Update the recording with the new definition $pylon->update(); $pylon->stop(); //Set the analyze parameters $parameters = array('analysis_type' => 'freqDist', 'parameters' => array('threshold' => 3, 'target' => 'fb.author.gender'), 'child' => array('analysis_type' => 'freqDist', 'parameters' => array('threshold' => 3, 'target' => 'fb.author.age'), 'child' => array('analysis_type' => 'freqDist', 'parameters' => array('threshold' => 3, 'target' => 'fb.author.highest_education')))); //Choose a filter $filter = 'fb.content contains "starbucks"'; //Analyze the recording
public function testFailCompile() { $csdl = '(fb.contwent any "coffee" OR fb.hashtags in "tea") AND fb.language in "en"'; $response = array('response_code' => 400, 'data' => array('error' => 'The target fb.contwent does not exist'), 'rate_limit' => 200, 'rate_limit_remaining' => 150); DataSift_MockApiClient::setResponse($response); $this->setExpectedException('DataSift_Exception_InvalidData'); $csdl = '(fb.contwent any "coffee" OR fb.hashtags in "tea") AND fb.language in "en"'; $pylon = new DataSift_Pylon($this->user); $pylon->compile($csdl); }