2017-08-28 1 views
0

Comment obtenir l'ID d'enquête par son nom dans SurveyMonkey? C'est ce qui est trouvé, mais comment le convertir en PHP?Comment obtenir un ID d'enquête par son nom dans SurveyMonkey

boucle -i -X ​​POST -H "Autorisation: porteur YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveymonkey.net/v3/surveys -d '{ "title": "Une nouvelle enquête"}

Voici mon appel api de base sans passer le paramètre title de l'enquête:

<?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); 
?> 

Merci.

Solution:

Ajouter

curl_setopt($ch, CURLOPT_POST, false); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 
+0

Que diriez-vous de lire leurs documents? –

+0

Copie possible de [Comment obtenez-vous l'identifiant du répondant à partir d'un sondage Survey Monkey?] (Https://stackoverflow.com/questions/19665652/how-do-you-get-the-respondent-id-from-a- enquête-singe-enquête) – user10089632

+0

je l'ai fait, le code curl -i -X ​​POST est saisir de leurs documents. – Jack

Répondre

0

j'ai trouvé la solution: ajouter les lignes suivantes: curl_setopt ($ ch, CURLOPT_POST, false); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ params);

0
$requestHeaders = array(
    'Content-Type: application/json', 
    'Authorization: Bearer MY_TOKEN', 
); 

$data = array(); 
$data['title'] = 'Zapier Tessfsdfsfdst'; 

$post_args = json_encode($data); 

$url = 'https://api.surveymonkey.net/v3/surveys/'; 
$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_args); 
curl_setopt($ch, CURLOPT_POST, false); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders); 

$arr = curl_exec($ch); 
curl_close($ch); 

Ceci est mon code, je tente d'obtenir ID surevy par titre, mais je reçois toutes les listes de l'enquête .. Pouvez-vous s'il vous plaît vérifier.