Search code examples
phpsms-gateway

Sms sending fails from php


I am using cs-networks SMS Gateway Api to send messages from my website, I'm generating url and when I copy to browser it works fine, but when I'm trying to send it from PHP code, it fails. My url is: http://api.cs-networks.net:9011/bin/send?USERNAME=my_username&PASSWORD=mypassword&SOURCEADDR=AMANATI&DESTADDR=user_number&MESSAGE=Hello+World

<?php
    $api_url = "http://api.cs-networks.net:9011/bin/send?USERNAME=my_username&PASSWORD=mypassword&SOURCEADDR=AMANATI&DESTADDR=user_number&MESSAGE=Hello+World";

    $result = file_get_contents($api_url); // fails

    // also fails
    $ch = curl_init($api_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);
?>

Can anybody tell me how to reffer this url from php to make it work?


Solution

  • Solved: So I contacted to my web hosting provider and explained them my problem, they told me that it could be because of closed port (90), so they opened port 90 and everything worked