如何在 SurveyMonkey 中按名称获取调查 ID

How to get survey ID by name in SurveyMonkey

如何在 SurveyMonkey 中通过名称获取调查 ID? 这是找到的,但是如何将其转换成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"}'

这是我的基本 api 调用,没有传递调查标题参数:

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

谢谢。

解决方案:

添加

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

我找到了解决方案:添加以下行: curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_POST字段, $params);