{“代码”:415,“消息”:“ HTTP 415不支持的媒体类型”} PHP

时间:2019-03-20 09:57:12

标签: php json curl

这是我用于POST CURL PHP的代码,同时尝试调用此代码,这给了我错误,我尝试按照API文档将内容类型为application / json,但实际上还是有人帮助我的相同代码,错误出在哪里或错误

$new_Bot_name = "testname";    
$data = array("body" => $new_Bot_name);
$data_string = json_encode($data);
$curl_hpost = curl_init('https://dashboard.chatfuel.com/api/bots/');
curl_setopt($curl_hpost, CURLOPT_HTTPHEADER,
        array(
            'Authorization: KEY_HERE',
            )
    );

    curl_setopt($curl_hpost, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl_hpost, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($curl_hpost, CURLOPT_RETURNTRANSFER, true);

    //execute post
    $result = curl_exec($curl_hpost);

    //close connection
    curl_close($curl_hpost);

    echo $result;

但是结果如下,有人可以帮助我

{"code":415,"message":"HTTP 415 Unsupported Media Type"}

0 个答案:

没有答案