Created
October 30, 2013 10:35
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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