PHP code example of ascension / php-surveymonkey

1. Go to this page and download the library: Download ascension/php-surveymonkey library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ascension / php-surveymonkey example snippets


$SM = new SurveyMonkey("myApiKey" , "myAccessToken");
$result = $SM->getSurveyList();
if ($result["success"]) print_r( $result["data"]["surveys"] );
else print_r($result["message"]);   // Print out the error message

$SM = new SurveyMonkey("myApiKey" , "myAccessToken",
    array(  // Override default API options (quite useless at the moment)
        'protocol' => 'http',                       // will not work.. they // ...<Any CURLOPT>...
    )
);
$result = $SM->getSurveyList(array(
    "fields" => array(
        "title",
        "analysis_url",
        "date_created",
        "date_modified",
        "question_count",
        "num_responses"
    ),
    'page_size' => 50,
    'page' => 2
));

/**
 * Retrieves a paged list of surveys in a user's account.
 * @see https://developer.surveymonkey.com/mashery/get_survey_list
 * @param array $params optional request array
 * @return array Result
 */
public function getSurveyList($params = array()){}

/**
 * Retrieves a paged list of collectors for a survey in a user's account.
 * @see https://developer.surveymonkey.com/mashery/get_collector_list
 * @param string $surveyId Survey ID
 * @param array $params optional request array
 * @return array Results
 */
public function getCollectorList($surveyId, $params = array()){}

/**
 * Retrieves a paged list of respondents for a given survey and optionally collector
 * @see https://developer.surveymonkey.com/mashery/get_respondent_list
 * @param string $surveyId Survey ID
 * @param array $params optional request array
 * @return array Results
 */
public function getRespondentList($surveyId, $params = array()){}

/**
 * Returns basic information about the logged-in user
 * @see https://developer.surveymonkey.com/mashery/get_user_details
 * @return array Results
 */
public function getUserDetails(){}

/**
 * Retrieves a paged list of templates provided by survey monkey.
 * @see https://developer.surveymonkey.com/mashery/get_template_list
 * @param array $params optional request array
 * @return array Results
 */
public function getTemplateList($params = array()){}

/**
 * Retrieves a paged list of templates provided by survey monkey.
 * @see https://developer.surveymonkey.com/mashery/create_collector
 * @param string $surveyId Survey ID
 * @param string $collectorName optional Collector Name - defaults to 'New Link'
 * @param string $collectorType 

/**
 * Create a survey, email collector and email message based on a template or existing survey.
 * @see https://developer.surveymonkey.com/mashery/create_flow
 * @param string $surveyTitle Survey Title
 * @param array $params optional request array
 * @return array Results
 */
public function createFlow($surveyTitle, $params = array()){}

/**
 * Create an email collector and email message attaching them to an existing survey.
 * @see https://developer.surveymonkey.com/mashery/send_flow
 * @param string $surveyId Survey ID
 * @param array $params optional request array
 * @return array Results
 */
public function sendFlow($surveyId, $params = array()){}