Php Survey Monkey 的 curl API - webhook
Php curl for Survey Monkey API - webhook
我在为 "Survey Monkey" 配置 webhook 时遇到问题。
根据 API 文档:Survey Monkey - webhook 我想我的代码中包含了所有必需的参数,但我仍然收到错误 "Invalid schema in the body provided"。这主要意味着 POSTed JSON 字符串数据有问题。但是我找不到问题所在...
我的卷曲:
$surveyId = '123456789';
$data_string = array(
'name' => 'my webhook 1233456789 name',
'event_type' => 'response_completed',
'object_type' => 'survey',
'object_ids' => array($surveyId),
'subscription_url' => 'http://sometunnel.ngrok.io/job-survey-monkey-listener/completed',
);
$data_string = json_encode($data_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.surveymonkey.net/v3/webhooks');
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: bearer 123myaccestoken456.abc.def', 'Content-Length: ' . strlen($data_string)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$server_output = curl_exec($ch);
curl_close($ch);
var_dump(json_decode($server_output, true)); die;
来自 Survey Monkey 的 return 的转储是:
array (size=1)
'error' =>
array (size=5)
'docs' => string 'https://developer.surveymonkey.com/api/v3/#error-codes' (length=54)
'message' => string 'Invalid schema in the body provided.' (length=36)
'id' => string '1002' (length=4)
'name' => string 'Bad Request' (length=11)
'http_status_code' => int 400
我做错了什么?
感谢General Kandalaft
Survey Monkey API 不接受用于制作 Curl 以创建新的 webhook 的整数...您必须将 Id 作为字符串发送。所以上面问题中的代码是正确的。
我在为 "Survey Monkey" 配置 webhook 时遇到问题。 根据 API 文档:Survey Monkey - webhook 我想我的代码中包含了所有必需的参数,但我仍然收到错误 "Invalid schema in the body provided"。这主要意味着 POSTed JSON 字符串数据有问题。但是我找不到问题所在...
我的卷曲:
$surveyId = '123456789';
$data_string = array(
'name' => 'my webhook 1233456789 name',
'event_type' => 'response_completed',
'object_type' => 'survey',
'object_ids' => array($surveyId),
'subscription_url' => 'http://sometunnel.ngrok.io/job-survey-monkey-listener/completed',
);
$data_string = json_encode($data_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.surveymonkey.net/v3/webhooks');
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: bearer 123myaccestoken456.abc.def', 'Content-Length: ' . strlen($data_string)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$server_output = curl_exec($ch);
curl_close($ch);
var_dump(json_decode($server_output, true)); die;
来自 Survey Monkey 的 return 的转储是:
array (size=1)
'error' =>
array (size=5)
'docs' => string 'https://developer.surveymonkey.com/api/v3/#error-codes' (length=54)
'message' => string 'Invalid schema in the body provided.' (length=36)
'id' => string '1002' (length=4)
'name' => string 'Bad Request' (length=11)
'http_status_code' => int 400
我做错了什么?
感谢General Kandalaft Survey Monkey API 不接受用于制作 Curl 以创建新的 webhook 的整数...您必须将 Id 作为字符串发送。所以上面问题中的代码是正确的。