PHP DEVELOP HELP

wmdpwijerathne

Junior member
  • May 19, 2014
    157
    21
    18
    යාලුවනේ මම SMS API gateway එකක් හදනවා (dialog ලගේ තම API එක) දැනට database එකෙන් customers ලාට dynamic sms යවන්න පුළුවන් .....

    එත් අවුල තියෙන්නේ message එකේ space තිබ්බොත් sms වෙන්නේ පලවෙනි word එක විතරයි

    මෙන්න code එක

    <?php
    require_once(dirname(__FILE__)."/classes/db-connection.php");
    $obj = new dbconnection();
    $con = $obj->getcon();

    $id_sms=$_POST["id_sms"];
    $today=date("Y/m/d/h");
    $pass="141**************";

    $sqlstatesms="SELECT * FROM msgtable WHERE id_sms ='$id_sms' ;";
    $resultsms=mysql_query($sqlstatesms,$con) or die ("SQL Error".mysql_error());
    $recordsms=mysql_fetch_array($resultsms);
    $msg_sms=$recordsms["msg"]; // get the msg from db

    $sqlstate="SELECT * FROM customer_reg_sms WHERE cuscontactnu1 LIKE '7%' ;";
    $result=mysql_query($sqlstate,$con) or die ("SQL Error".mysql_error());
    $rownumber=mysql_num_rows($result);


    while($record=mysql_fetch_array($result)){
    $cusid=$record["customerid"];
    $bal=$record["balance"];
    $lp=$record["lastpayment"];
    $getp=$record["cuscontactnu1"];
    $pnumber ="94".$getp;

    $msg=$msg_sms." ".$bal." and your last payment is".$lp."***xxxxxxxxxxxxxxxxxxxx (011-5******)***"; //set the msg

    // echo $y = "https://cpsolutions.dialog.lk/index.php/cbs/sms/send?destination=".$pnumber."&q=".$pass."&message=".$msg; ?> </br><?php

    when echo this "$y" out come will be
    https://cpsolutions.dialog.lk/index.php/cbs/sms/send?destination=94778119027&q=14181866758&message=Dear customer your due amount is 2000.00 and your last payment is 4500.00***xxxxxxxxxxxxx(011-xxxxxxx)***


    If I copy and paste the above URL on address bar (with correct password) complete SMS send successfully

    //$resultstu =file_get_contents("$y");

    above code I used to get the response value from the dialog API gateway
    and it gives correctly ,,,but sms send with the first word only in this..only "Dear"


    }



    $obj->close();
     
    Last edited:

    wmdpwijerathne

    Junior member
  • May 19, 2014
    157
    21
    18
    API SMS

    $y = "https://cpsolutions.dialog.lk/index.php/cbs/sms/send?destination=".$pnumber."&q=".$pass."&message=".rawurlencode($msg); ?> </br><?php


    Thanks all it working
     

    chanakaisuru

    Active member
  • May 20, 2009
    202
    28
    28
    kiribathgoda


    මචන් මේ sample එක try කරලා බලපන් parameters ටික උබේ ඒවාට මාරු කර ගනින්.

    <?php
    $base_url = "https://cpsolutions.dialog.lk/index.php/cbs/sms/send"; //Url address for sending SMS
    $username = "username";
    $password = "password";
    $src = "sms sender id";
    $str = $_REQUEST["recipient"];
    $dst = "94" . substr($str, 1);
    $msg = $_REQUEST["message"];

    $params = array(
    'username' => $username,
    'password' => $password,
    'src' => $src,
    'dst' => $dst,
    'msg' => $msg,
    );
    $data = '?'.http_build_query($params);
    $ret = fopen($base_url.$data,'r');
    $result = fread($ret,1024);
    fclose($ret);
    echo $result;

    ?>
     

    ajithparakrama

    Active member
  • May 15, 2015
    376
    84
    28
    machan sms eke space tika &bsp; walin replace karala balapan.
    or
    Server Character Set and Collation may be the case, character format eke wenas wenna puluwa.