Skip to content

Instantly share code, notes, and snippets.

@theinventor theinventor/rs_post.php
Last active Jul 17, 2019

Embed
What would you like to do?
<?php
if( $_POST["name"] )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://YOUR_SUBDOMAIN.host.com/api/v1/leads?api_key=YOUR_API_KEY");
curl_setopt($ch, CURLOPT_POST, 1);
// example splitting a name field into first and last name bits
$pieces = explode(" ", $_POST['name']);
$last_name_parts = array_slice($pieces, 1); //each word
$last_name = implode(" ", $last_name_parts); //combined words, with space separators
// build up the lead post data here, you can combine fields into the data you are sending
// see subject for an example
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('first_name' => $pieces[0],
'last_name' => $last_name,
'email' => $_POST['email'],
'phone' => $_POST['phone'],
'ticket_problem_type' => $_POST['problem'],
'city' => $_POST['city'],
'ticket_subject' => $_POST['device'] . " Pri: " . $_POST['priority'],
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
//redirect to thanks page
header("Location: /thanks.html");
exit();
}
?>
<html>
<body>
<form action="<?php $_PHP_SELF ?>" method="POST">
Name: <input type="text" name="name" /> <br>
Email: <input type="text" name="email" /><br>
Phone: <input type="text" name="phone" /><br>
Problem: <input type="text" name="problem" /><br>
City: <input type="text" name="city" /><br>
Device Type: <select name='device'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<br>
Priority: <select name='priority'>
<option value="p3">Low</option>
<option value="p2">Medium</option>
<option value="p1">High</option>
</select>
<br>
<input type="submit" />
</form>
</body>
</html>
@techinaflash

This comment has been minimized.

Copy link

commented Aug 8, 2014

Can you provide an example of POSTing an invoice. I can't get the line_items to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.