Ok, I am stuck. Here is what I have:
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
// include script configuration
require_once 'config.php';
//Retrieving Webhook
$json = file_get_contents('php://input');
$data = json_decode($json, TRUE);
//Gathering Data Variables
$order_id = $data[0]["order"]["id"];
$email = $data[0]["order"]["billing_address"]["email"];
$total = $data[0]["order"]["total"];
$paid = $data[0]["order"]["status"];
//print_r($data[0]["order"]["billing_address"]["email"]);
//Knack API PUT Script
global $kn_appID;
global $kn_APIKey;
// Create an array of the fields being included in the call
$jsonarray["field_1032"] = $order_id;
$jsonarray["field_1033"] = array("email" => $email);
$jsonarray["field_1034"] = $total;
$jsonarray["field_1035"] = $paid;
//Encode array into json
$jsonstring = json_encode($jsonarray);
//Update the record in Knack
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.knack.com/v1/objects/object_62/records/");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonstring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "X-Knack-Application-Id: " . $kn_appID, "X-Knack-REST-API-Key: " . $kn_APIKey));
$returnVal = json_decode(curl_exec($ch));
?>
ok so here is the deal, when I set the variable with the same json that I am getting when I use requestb.in as my endpoint it works fine. However, when using file_get_contents('php://input');
I am getting this error:
Status: HTTP 200 OK: Notice: Undefined offset: 0 in /home3/nzshumate/public_html/bc/get_info.php on line 21
Any direction on what I am doing wrong here would be appreciated.