嗨,我在向我的 API发布JSON
数组时遇到问题,cURL
我在下面有这个cURL
帖子的代码:
$data_string = stripslashes($JSONData);
$ch = curl_init('http://api.webadress.com');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
它不会将任何内容存储/发布到 API 端,并且 $results 没有返回正确,代码有什么问题?
有点来自JSON
:
{
"name": "test",
"type_id": "1",
"css": "#fb-iframe{}#fb-beforelike{}#fb-beforelike-blur{}",
"json": [
{
"Canvas": [
{
"Settings": {
"Page": {
"campaignName": "test"
}
},
"QuizModule": {
"Motivation": [],
"Questions": [],
"Submit_Fields": [
{
"label": "Name",
"name": "txtName",
"value": true
}
]
}
}
]
}
],
"user_id": "123"
}