0

I am sending SMS from my bus ticketing site. The SMS can be send as follows :

header('Location: http://alerts.icisms.in/api/web2sms.php?workingkey=XXXXXX&sender=ABCD&to='.$number.'&message='.$message);

But I need to return to my own site.How can I accomplish this?

AssamGuy
  • 1,571
  • 10
  • 30
  • 43

3 Answers3

6

You make an HTTP request using PHP (e.g. with the cURL library or fopen).

You don't give your key to the user and ask their browser to make the request to the API.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks for your response. How can I do it using fopen() ? `$handle = fopen("http://alerts.icisms.in/api/web2sms.php?workingkey=XXXXXX&sender=ABCD&to=".$number."&message=".$message", "w");` I am wrong? – AssamGuy Jul 11 '12 at 12:59
3

From the looks of it you would just be able to do a simple request to this page.

You can achieve this using either the CURL functions or simply using file_get_contents to perform a single GET request.

By using header you're redirecting the client which is unnecessary and potentially unsecure. EDIT: Scrap potentially, you've got an authentication key in there so giving that to your third-party users is not a good thing to do at all.

Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
3

Use cURL or a simple file()/file_get_contents() call.

//call
$url = 'http://alerts.icisms.in/api/web2sms.php?workingkey=XXXXXX&sender=ABCD&to=' . $number . '&message=' . $message;

//do call
file($url);

Then set your header location to your site.

Kermit
  • 33,827
  • 13
  • 85
  • 121
  • Ok..its working but not 100% ! because if `$message = 'Dear Mr. XXXX XXXXX,etc etc...'` only `Mr` is coming to mobile ! – AssamGuy Jul 11 '12 at 13:04
  • 4
    @AssamGuy does your SMS provider have an API? Replace `$message` above with `urlencode($message)` – Kermit Jul 11 '12 at 13:05