Siren Brown Siren Brown - 1 year ago 71
PHP Question

How to set curl into php

<form action="mail.php" method="post">

<label class="form-label" for="name">Full Name</label>
<input class="user" type="text" name="name" id="name">

<label class="form-label" for="email">Email Id</label>
<input class="email" type="email" name="email" id="email">


This is my form.

How can I set this curl code into php for this form?

Create a new User
Users can be created or updated via a POST method to, which accepts a JSON object describing the user.

Example request:

curl \
-u app_id:api_key \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' -d '
"email": ""

Answer Source

I hope this will work,

    $url = '';
    $headers = array(
                        'Accept: application/json',
                        'Content-Type: application/json'
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS,  json_encode($array));
    curl_setopt($ch, CURLOPT_USERPWD, 'app_id:api_key');
    $result = curl_exec($ch);