首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Php curl for Survey Monkey API - webhook

Php curl for Survey Monkey API - webhook
EN

Stack Overflow用户
提问于 2017-06-25 01:59:22
回答 0查看 560关注 0票数 1

我在配置"Survey Monkey“的网络钩子时遇到问题。根据API docs:Survey Monkey - webhook,我想我已经在代码中包含了所有必需的参数,但仍然收到错误消息"Invalid schema in the body provided“。这主要意味着POSTed JSON字符串数据有问题。但我找不到哪里不对劲。

我的卷发:

代码语言:javascript
复制
$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返回的转储是:

代码语言:javascript
复制
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

我在这里做错了什么?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44739380

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档