Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
FoxyCart API - Ajax to PHP and back for customer info
url: '../assets/php/get_customer_id.php',
data: { email: "" },
type: 'post',
success: function(data) {
var xmlDoc = $.parseXML(data),
$xml = $(xmlDoc);
error: function(jqXHR, textStatus, errorThrown) {
console.log("ERROR", jqXHR, textStatus, errorThrown);
//Checks if action value exists
if (isset($_POST["email"]) && !empty($_POST["email"])) {
$email = $_POST["email"];
$foxy_domain = "";
$foxyData = array();
$foxyData["api_token"] = "XXX Your Key XXX";
$foxyData["api_action"] = "customer_get";
$foxyData["customer_email"] = $email;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
// If you get SSL errors, you can uncomment the following, or ask your host to add the appropriate CA bundle
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = trim(curl_exec($ch));
// The following if block will print any CURL errors you might have
if ($response == false) {
print "CURL Error: \n" . curl_error($ch);
} else {
print $response;
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.