I have to send an SMS by making an HTTP request via GET method. The link contains information in the form of GET variables, e.g.
http://www.somelink.com/file
Lets assume that we want to retrive http://www.google.com
$cURL = curl_init();
$setopt_array = array(CURLOPT_URL => "http://www.google.com", CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array());
curl_setopt_array($cURL, $setopt_array);
$json_response_data = curl_exec($cURL);
print_r($json_response_data);
curl_close($cURL);
/* cURL is preinstalled by goDaddy.com and many other php hosting providers it is also preinstalled in wamp and xampp good luck. */
I think the easiest way to make an HTTP request via GET method from PHP is using file_get_contents().
<?php
$response = file_get_contents('http://example.com/send-sms?from=12345&to=67890&message=hello%20there');
echo $response;
Don’t forget to see the notes section for info on PHP configuration required for this to work. You need to set allow_url_fopen
to true in your php.ini
.
The easiest way is probably to use cURL. See http://codular.com/curl-with-php for some examples.