* User: tanish
 * Date: 10/21/15
 * Time: 12:57 PM
 */
session_start();
require __DIR__ . "/SurveyMonkey-api-class.php";
//define('API_KEY', 'wxy8bfy2kdjfjdkuhxcrchsu');
//define('CLIENT_ID', 'apisquarestack');
//define('API_SECRET', 'ZSrge9nssrXqeX7RYEsqAF7mJSe6k4ZT');
define('API_KEY', '9ke3sjx8rcymfftpmtfpfkvj');
define('CLIENT_ID', 'squarestack2');
define('API_SECRET', 'WtJh729n279s7ESP2Uwc3cEKKkJ6faXt');
define('REDIRECT_URL', 'http://localhost:63342/php-surveymonkey/api-surveyMonkey.php/');
//Example :
//THe sleeps between the calls is because the surveymonkey has a limited API rate of 2 calls per
$provider = new SurveyMonkey(API_KEY, CLIENT_ID, API_SECRET, REDIRECT_URL);
$provider->initialAuthentication();
sleep(1);
//get the list of last 1000 surveys
$last1000SurveysArray = $provider->getLastNSurveyList(1000);
$survey1ID = $last1000SurveysArray[0]['survey_id'];
sleep(1);
//Left side accourding to task
$countsOverDayWeekMonth = $provider->getResponsesOverDayWeekMonth($survey1ID);
echo "day: " . $countsOverDayWeekMonth['lastDay'] . "\n";
echo "week: " . $countsOverDayWeekMonth['lastWeek'] . "\n";
echo "month:  " . $countsOverDayWeekMonth['lastMonth'] . "\n";
sleep(1);
//Middle for a given survey ID, it gets the completion rate
$surveyCompletionRate = $provider->getSurveyCompletionRate($survey1ID);
echo "started: " . $surveyCompletionRate['started'] . "\n";
Example #2
0
<?php

/**
 * Test initialization
 * @package php-surveymonkey
 * @subpackage tests
 */
require_once 'config.inc.php';
require_once '../SurveyMonkey.class.php';
/** @var SurveyMonkey Initialize SurveyMonkey class */
$survey_monkey = new SurveyMonkey($api_key, $access_token);
// Try to get first survey_id,  if not manually defined above
if (empty($survey_id)) {
    $results = $survey_monkey->getSurveyList();
    if ($results["success"]) {
        $surveys = $results["data"]["surveys"];
        if (count($surveys) === 0) {
            echo "ERROR: You must create a survey on surveymonkey!";
            die;
        }
        $survey_id = $surveys[0]["survey_id"];
        // get first survey's id
        echo "Auto selecting first survey: {$survey_id} \n\r";
    } else {
        echo "ERROR: " . $results["message"];
        die;
    }
}
/**
 * Handle returned results
 * @param  string  $name  Title of test
<?php

require_once '../SurveyMonkey.class.php';
/**
 * Call all methods using PHP SDK for SurveyMonkey API v2
 * @package default
 */
//////////////////////////////////////////////////////////
//AUTH
//////////////////////////////////////////////////////////
$api_key = 'YOURAPIKEY';
$access_token = 'YOURACCESSTOKEN';
$survey_monkey = new SurveyMonkey($api_key, $access_token);
//////////////////////////////////////////////////////////
//GET SURVEY LIST
//////////////////////////////////////////////////////////
$params = array('order_asc' => false, 'fields' => array('title', 'preview_url', 'date_created', 'date_modified', 'question_count'));
$list = $survey_monkey->getSurveyList($params);
print_r($list);
//////////////////////////////////////////////////////////
//GET SURVEY DETAILS
//////////////////////////////////////////////////////////
$survey_id = 'SURVEYID';
$details = $survey_monkey->getSurveyDetails($survey_id);
print_r($details);
//////////////////////////////////////////////////////////
//GET COLLECTOR LIST
//////////////////////////////////////////////////////////
$survey_id = 'SURVEYID';
$params = array('page_size' => 10, 'order_asc' => false, 'fields' => array('title', 'preview_url', 'date_created', 'date_modified', 'question_count'));
$list = $survey_monkey->getCollectorList($survey_id, $params);