Blerta Blerta
Blerta Blerta

Reputation: 35

How to communicate with SMS gateway via PHP

I have a link I need users to click in order for them to receive a text message. The URL points to an external link so I can't mask it. At present when a user clicks on the link I redirect them to the external site to send the message, but I do not wish to do this as I don't want the user to see the external URL.

I have tried to use file_get_contents() and cURL but I have been unable to get either mechanism to work. When I load the page in the browser I get the text response "OK", when I use PHP to make the request I get the "OK" response from the server but I do not receive the text message to my phone.

Here is the cURL code I have tried:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);

return $output;

Upvotes: 1

Views: 227

Answers (1)

Jay
Jay

Reputation: 193

Using twilio may be able to save you some time here.

Note: Only wrote this here because I cant comment for some reason.

Upvotes: 1

Related Questions