0

I trying to send sms message to users using php language . I using curl to send this message but I have this error

{"error":"HTTP 405 Method Not Allowed"}

I used Clickatell as sms api . this is my code

echo $url= 'https://platform.clickatell.com/messages/http/sendapiKey=ordnzDdGdRhqdnjdf3ZmzYA==&to=904234234&content=your+password+is+BhSTV';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
echo $response = curl_exec($ch);
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Abobaker EngIt
  • 37
  • 1
  • 10
  • try to use `GET` instead of `POST`, as `GET`, like `HEAD`, cannot be disallowed – Kaddath Jan 19 '18 at 13:48
  • 1
    better to use their php lib [here](https://www.clickatell.com/developers/api-documentation/php-library/) – Shalitha Suranga Jan 19 '18 at 13:59
  • Take a look at this [example](https://github.com/clickatell/clickatell-otp-example/blob/master/src/otp.php) - I also recommend doing a GET as @Kaddath mentioned, your telling Curl its a POST with this line `curl_setopt($ch,CURLOPT_POST,1);` – JGlass Jan 19 '18 at 14:16
  • thank you very much that worked perfect . – Abobaker EngIt Jan 19 '18 at 14:20
  • Glad to see it helped! Feel free to mark it as helpful - since I didnt "answer" your question as an answer - have a great day! – JGlass Jan 22 '18 at 15:20

1 Answers1

0

It looks like your URL is incorrect. Try this: https://platform.clickatell.com/messages/http/send?apiKey=ordnzDdGdRhqdnj...

Floern
  • 33,559
  • 24
  • 104
  • 119