【发布时间】:2014-09-05 23:02:51
【问题描述】:
我在将 curl 命令转换为 php 时遇到问题。
这部分效果很好。
将条目添加到我的 Parse.com 数据库的 CURL 命令:
curl -X POST \
-H "X-Parse-Application-Id: my_id" \
-H "X-Parse-REST-API-Key: api_id" \
-H "Content-Type: application/json" \
-d "{\"SiteID\":\"foundID\",\"dataUsedString\":\"foundUsage\",\"usageDate\":\"foundDate\", \"monthString\":\"foundMonth\", \"dayString\":\"foundDay\",\"yearString\":\"foundYear\"}" \
https://api.parse.com/1/classes/MyClass
已解决的答案:
我创建了这个 php 脚本来复制命令:
<?php
$ch = curl_init('https://api.parse.com/1/classes/MyClass');
curl_setopt($ch,CURLOPT_HTTPHEADER,
array('X-Parse-Application-Id:my_id',
'X-Parse-REST-API-Key:api_id',
'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"SiteID\":\"foundID\",\"dataUsedString\":\"foundUsage\",\"usageDate\":\"foundDate\", \"monthString\":\"foundMonth\", \"dayString\":\"foundDay\",\"yearString\":\"foundYear\"}");
curl_exec($ch);
curl_close($ch);
?>
【问题讨论】:
-
你从远程服务器得到什么响应?
-
已解决!!!!谢谢@valentin 和 cOle2
标签: php post curl parse-platform