Overview

Packages

  • php-surveymonkey
    • exception

Classes

  • SurveyMonkey
  • Overview
  • Package
  • Class

Class SurveyMonkey

Class for SurveyMonkey API v2

Package: php-surveymonkey
Located at SurveyMonkey.class.php
Methods summary
public static
# successfulHttpResponse( $code )
public static string
# explainStatusCode( integer $code )

Explain Survey Monkey status code

Explain Survey Monkey status code

Parameters

$code
Status code

Returns

string
Definition
public SurveyMonkey
# __construct( string $apiKey, string $accessToken, array $options = array(), array $connectionOptions = array() )

The SurveyMonkey Constructor.

The SurveyMonkey Constructor.

This method is used to create a new SurveyMonkey object with a connection to a specific api key and access token

Parameters

$apiKey
A valid api key
$accessToken
A valid access token
$options
(optional) An array of options
$connectionOptions
(optional) cURL connection options

Returns

SurveyMonkey
A unique SurveyMonkey instance.

Throws

SurveyMonkey_Exception
If an error occurs creating the instance.
protected string
# buildUri( string $endpoint )

Build the request URI

Build the request URI

Parameters

$endpoint
API endpoint to call in the form: resource/method

Returns

string
Constructed URI
protected boolean
# getConnection( )

Get the connection

Get the connection

Returns

boolean
protected
# closeConnection( )

Close the connection

Close the connection

protected array
# run( string $endpoint, array $params = array() )

Run the

Run the

Parameters

$endpoint
$method API method to run
$params
Parameters array

Returns

array
Results
protected array
# failure( string $msg )

Return an error

Return an error

Parameters

$msg
Error message

Returns

array
Result
protected array
# success( string $data )

Return a success with data

Return a success with data

Parameters

$data
Payload

Returns

array
Result
public array
# getSurveyList( array $params = array() )

Retrieves a paged list of surveys in a user's account.

Retrieves a paged list of surveys in a user's account.

Parameters

$params
optional request array

Returns

array
Result

See

https://developer.surveymonkey.com/mashery/get_survey_list
public array
# getSurveyDetails( string $surveyId )

Retrieve a given survey's metadata.

Retrieve a given survey's metadata.

Parameters

$surveyId
Survey ID

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_survey_details
public array
# getCollectorList( string $surveyId, array $params = array() )

Retrieves a paged list of collectors for a survey in a user's account.

Retrieves a paged list of collectors for a survey in a user's account.

Parameters

$surveyId
Survey ID
$params
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_collector_list
public array
# getRespondentList( string $surveyId, array $params = array() )

Retrieves a paged list of respondents for a given survey and optionally collector

Retrieves a paged list of respondents for a given survey and optionally collector

Parameters

$surveyId
Survey ID
$params
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_respondent_list
public array
# getResponses( string $surveyId, array $respondentIds, integer $chunkSize = 100 )

Takes a list of respondent ids and returns the responses that correlate to them.

Takes a list of respondent ids and returns the responses that correlate to them.

Parameters

$surveyId
Survey ID
$respondentIds
Array of respondents IDs to retrieve
$chunkSize
optional number of respondants to fetch in each chunk. We split it to multiple requests to conform with SurveyMonkey's API limits. If successful, the returned array is a joined array of all chunks.

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_responses
public array
# getResponseCounts( string $collectorId )

Returns how many respondents have started and/or completed the survey for the given collector

Returns how many respondents have started and/or completed the survey for the given collector

Parameters

$collectorId
Collector ID

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_response_counts
public array
# getUserDetails( )

Returns basic information about the logged-in user

Returns basic information about the logged-in user

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_user_details
public array
# getTemplateList( array $params = array() )

Retrieves a paged list of templates provided by survey monkey.

Retrieves a paged list of templates provided by survey monkey.

Parameters

$params
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/get_template_list
public array
# createCollector( string $surveyId, string $collectorName = null, string $collectorType = 'weblink', array $params,… )

Retrieves a paged list of templates provided by survey monkey.

Retrieves a paged list of templates provided by survey monkey.

Parameters

$surveyId
Survey ID
$collectorName
optional Collector Name - defaults to 'New Link'
$collectorType
required Collector Type - only 'weblink' currently supported
$params,…
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/create_collector
public array
# createFlow( string $surveyTitle, array $params = array() )

Create a survey, email collector and email message based on a template or existing survey.

Create a survey, email collector and email message based on a template or existing survey.

Parameters

$surveyTitle
Survey Title
$params
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/create_flow
public array
# sendFlow( string $surveyId, array $params = array() )

Create an email collector and email message attaching them to an existing survey.

Create an email collector and email message attaching them to an existing survey.

Parameters

$surveyId
Survey ID
$params
optional request array

Returns

array
Results

See

https://developer.surveymonkey.com/mashery/send_flow
Constants summary
integer SM_STATUS_SUCCESS

Const

SurveyMonkey Status code: Success
# 0
Properties summary
protected string $_apiKey

API key

API key

#
protected string $_accessToken

API access token

API access token

#
protected string $_protocol

API protocol

API protocol

#
protected string $_hostname

API hostname

API hostname

#
protected string $_version

API version

API version

#
protected array $_connectionOptions

(optional) cURL connection options

(optional) cURL connection options

#
public static array $SM_STATUS_CODES

SurveyMonkey API Status code definitions

SurveyMonkey API Status code definitions

# array( 0 => "Success", 1 => "Not Authenticated", 2 => "Invalid User Credentials", 3 => "Invalid Request", 4 => "Unknown User", 5 => "System Error", 6 => "Plan Limit Exceeded" )
API documentation generated by ApiGen