Hello,
With PHP, i am trying to generate pass from one of the template of my project. Below is my code, which is not working. Use below code, change template id, login email and API key to check this.
$fields = array(
'publicURL' => 'single',
'msg' => 'Testing msg only.',
'Passenger' => 'Test Passenger',
'Boarding Pass Details' => 'This text is automated'
);
$create_pass = get_curl_data('https://wallet-api.urbanairship.com/v1/pass/123456', $fields);
$create_passArr = json_decode($create_pass);
echo rand();
echo '<pre>';
print_r($create_passArr);
echo '</pre>';
function get_curl_data($url, $fields){
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_USERPWD, 'xxxxLOGINEMAILxxxx:xxxxAPIKEYxxxx');
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($fields));
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded', 'Api-Revision:1.2'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
return $result;
}
After executing above code, i am getting below error message.
stdClass Object ( [code] => 406 [description] => Not Acceptable Request. [details] => Error parsing JSON request string,msg= null )
Can anyone help me on this?
Thanks
Comments
2 comments