0
votes

How to get survey ID by name in SurveyMonkey? This is what is found, but how to convert this into PHP?

curl -i -X POST -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveymonkey.net/v3/surveys -d '{"title":"New Survey"}'

Here is my basic api call without passing the survey title parameter:

<?php
$requestHeaders = array(
    'Content-Type: application/json',
    'Authorization: Bearer 12345',
);

$url = 'https://api.surveymonkey.net/v3/surveys/';
$ch  = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_contactlist);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
?>

Thanks.

Solution:

Add

curl_setopt($ch, CURLOPT_POST, false); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
1
What about reading their docs?B001ᛦ
i did, the code curl -i -X POST is grab from their docs.Jack
You already have the PHP code, just do curl_exec($ch); and let us know what the exact issue is then. -d parameter equivalent in curl PHP: stackoverflow.com/questions/25032517/…Daniel W.
But i need to pass the param "title:New Survey" for searching/filtering.Jack

1 Answers

0
votes

i found the solution: add the following lines: curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $params);