Hi guys! I have recieved a cUrl script that I want to incorporate in my homepage. It will register people for a site. I have only recieved the cUrl code without proper guidance. First I only pasted the code in a php file but then I realized that I need some kind of input form. So checked a bit of youtube. Here is what I got so far:
The form
<fieldset> <legend>Form</legend> <form action="test.php" method="post"> <label>Full Name: </label><input type="text" name="fullname" /><br /> <label>Email: </label><input type="text" name="email" /><br /> <input type="submit" name="submit" value="submit" /> </form> </fieldset>
And script
<?php
$apiUrl = "https://udimi.com/api/affgen/addref";
$headers = [
"Content-Type: application/json",
"Auth: Generated auth code here"
];
$referral = [
'fullname' => 'Referral Fullname',
'email' => '[email protected]'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($referral),
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
I was quite happy because it ended up in the homepage as a “pending user” basically. But, the name and email was the same as in the code above, Referral fullname and [email protected]
So I think I am getting close. Any pointers here?