I've never used a forum like this before, but hey ho, I've put the books down, and I'm at your mercy...
I've bought this device called an SMS2Printer... anyhow, I'm playing about with it, and essentially I send it a post/get request through a remote API and it has a number of variables... username, password, etc... and "print_message" - the SMS printer remotely will print whatever is in the "print_message". So far so good.
Only problem is, when it prints, the page returned to the user is XML formatted:
<result>
<status>success</status>
</result>
As i've never done anything like this before, I was wondering if anyone could point me in the right direction of how to receive the above and reformat it... i mean, in an ideal world I'd like to run a request over to this printer in the background, and keep the user in my PHP app.
The application is for my brother's takeout restaurant, for online ordering. I'm doing it as a favour for him, but I'm really confused, and I can't let him down!
I tried cURL:
Code: Select all
$url = "https://sms2printer.com/manage/api/";
$msg = "?apiver=1&imei=123456789012345&password=abcdefghi&action=print&print_message=2010-06-21 A Test message sent to the SMS Printer.";
sendcallback($url,$msg);
function sendcallback($scripturl,$message){
$message=urlencode($message);
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, '.$scripturl.$message.');
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
}