the jquery function below is a sample script from boomerang. It is their GetSendList function. I was trying to make a php version of it but still unsuccessful. Here's the function:
function GetSendList() {
var r = new Object;
r = [
{
email: $("#txt-SendList-email-0").val(),
jobNumber: $("#txt-SendList-jobNumber-0").val()
},
{
email: $("#txt-SendList-email-1").val(),
jobNumber: $("#txt-SendList-jobNumber-1").val()
}
]
var dataString = JSON.stringify(r);
$.ajax({
type: "POST",
url: "https://target.boomerang.com/V1.0/api/SendList",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
data: dataString,
headers: { auth_token: $('#txtAuthenticationCode').val() },
success: function (response) {
}
});
}
Here's my PHP script:
$main_url = "https://target.boomerang.com/V1.0/api/";
$token = "xxx";
$values = array('email'=>'email',
'jobNumber'=>'jobnumber'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$main_url."SendList");
curl_setopt($ch,CURLOPT_HTTPHEADER,array('auth_token: '.$token));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($values));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$output = json_decode($server_output);
I'm guessing I have a wrong formatting for my values that's why I'm unsuccessful. I do not know the equivalence of jquery object in PHP.
PS. I use the same php script to call their other functions and Im successful with those. It's only the GetSendList that I'm having problem right now. Please advice. Thanks!