Posting JSON data to API using CURL

后端 未结 3 1716
逝去的感伤
逝去的感伤 2021-01-04 10:15

When I\'m posting json data to API using curl - I\'m not getting any output. I would like to send email invitation to recipient.

$         


        
3条回答
  •  孤独总比滥情好
    2021-01-04 10:36

    You have to add header:

    $headers= array('Accept: application/json','Content-Type: application/json'); 
    

    And:

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    

    Otherwise ...

    HTTP Status 415 - Unsupported Media Type

    ... may happen.

提交回复
热议问题