Curl problem

Discussion in 'PHP' started by Fracisc, Oct 1, 2016.

  1. #1
    I have this:

    curl -H "Content-Type: application/json" -X POST -d '{"user":{"email":"mail@example.com","password":"secret"}}' -i https://url.com
    PHP:
    Mandatory header for any request is Content-Type: application/json.


    I need to use simple php code instead of command line. How can I do that?
     
    Fracisc, Oct 1, 2016 IP
  2. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #2
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'SOME HEADER',
        'APPTYPE:JSON'
        ));
    PHP:
    Just use curl_setopt
     
    Einheijar, Oct 2, 2016 IP