我在 PHP 中使用 cURL 来访问 Asana API。
我很高兴将我的值作为 GET 附加到 URL,但现在,随着我的应用程序变大,我发布的数据越来越多,所以我一直在尝试将其转换为发布。
到目前为止,我已经尝试过:
setting post['data'] to a json object {key:value,key:value}
setting post['data'] to a json object {options:{key:value,key:value}}
setting post['data'] to a json object {data:{options:{key:value,key:value}}}
setting post['data'] to a json object {data:{key:value,key:value}}
setting post['body'] to all of the above json objects
到目前为止,对于我的方法,我最终得到了错误:
Could not parse request data, invalid JSON
当然,使用 cURL,我正在这样做:
$post = json_encode($myFields);
curl_setopt(CURLOPT_POSTFIELDS,array('data'=>$post));
对于所有这些测试,我将输出 JSON 并使用 JSLint 对其进行验证。这是非常有效的 JSON,所以问题绝对不是那个。我只需要知道为什么它无效。
我只是不能让它工作。感谢您的帮助-丹尼尔。