Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Created October 30, 2013 10:35
Show Gist options
  • Save hagbarddenstore/7230453 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/7230453 to your computer and use it in GitHub Desktop.
A small example on how to use the MobileResponse HTTP API via PHP with cURL.
<?php
$data = array(
'data' => array(
'username' => 'username',
'password' => 'password',
'senderName' => 'SndrName',
'message' => 'The message',
'recipients' => array(
'+46700000000'
)
)
);
$json = json_encode($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.mobileresponse.se/quickie/send-message');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($json)));
// For some reason, cURL doesn't accept our SSL certificate.
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$return_json = curl_exec($curl);
echo $return_json;
// Uncomment if it doesn't work.
// echo curl_error($curl);
curl_close($curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment