douhensheng1131 2017-06-09 18:25
浏览 50

在Geckoboard php curl中获取无效的JSON错误

I am trying to add data in Geckoboard dataset using php curl but i am getting invalid json error. Please help me.

Please check my below code:

$ch = curl_init('https://api.geckoboard.com/datasets/sales.datasetidhere/data');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = array("articlePublished" => "6"); 
$data = json_encode($data);
curl_setopt($ch, CURLOPT_POST, 1); 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_USERPWD, "Key:");

curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt($ch, CURLOPT_POSTFIELDS, 'data='.$data);

$response = curl_exec($ch);
$headers = curl_getinfo($ch);
print_r( $headers );
print_r( $response );

Here is the response: {"error":{"message":"Invalid JSON was received by the server."}}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器