Jump to content

SMS fetching is not working too much time


paresh15

Recommended Posts

Hi,

 

I am working on coupon script which generate coupon.

 

The coupon script have two types, one is redemption and second one is printable in the same process it send sms to customer.

 

But issue is when it send SMS, sometime SMS works nice and lots of time SMS content got missing.

I could not understand why it happening. Is it scripting issue or another?

 

The script code as below:

 

----------------------------------------------------------------------------------------------------------

//Send coupon code to customer by SMS

                        $smsparameters = "select * from cs_options where option_id in ('23','24','25','26')";

                        if(!($smsparametersresult = mysql_query($smsparameters))) { echo $smsparameters.mysql_error(); exit; }

                        while($smsparametersrow = mysql_fetch_array($smsparametersresult)) {

                                    $smsparametersarray[] = $smsparametersrow['option_value'];

                        }                                 

                        define('SMS_SERVICE_URL', $smsparametersarray[0]);

                        define('KEY', $smsparametersarray[1]);

                        define('USERNAME', $smsparametersarray[2]);

                        define('PASSWORD', $smsparametersarray[3]);                                          

                       

                        $automationquery = "select * from cs_automation where automation_id='6'";

                        if(!($automationresult = mysql_query($automationquery))) { echo $automationquery.mysql_error(); exit; }

                        $automationrow = mysql_fetch_array($automationresult);

                        $automationrow['automation_value'];

                        if($automationrow['automation_value']=='1') {

                                               

                                    $sms_order_id = $_SESSION['new_order_id'];                   

                                    $current_date = date('Y-m-d');                                  

                                    $smsquery = "select * from cs_order as ord left join cs_customer as cust on ord.order_user_id = cust.customer_id where ord.order_id = '$sms_order_id'";

                                    if(!($smsresult = mysql_query($smsquery))) { echo $smsquery.mysql_error(); exit; }                                   

                                    $sms_items = mysql_fetch_assoc($smsresult);

                                   

                                    $order_coupon_id4 = explode(", ", $customer_email_items['order_coupon_id']);                                                                           

                                   

                                    foreach($order_coupon_id4 as $coup_id) {

                                                $coupon_id = $coup_id['order_coupon_id'];

                                                $query = "select * from cs_coupons as coup inner join cs_company as comp on coup.coupons_store = comp.retailer_id inner join cs_payments_currency as curr on coup.coupons_currency_id = curr.currency_id inner join cs_countries as cont on comp.country = cont.country_id inner join cs_states as stat on comp.state = stat.state_id inner join cs_cities as citi on comp.city = citi.city_id inner join cs_area as aria on comp.local_area = aria.area_id where coup.coupons_id = '$coupon_id'";

                                               

                                                if(!($result = mysql_query($query))) { echo $query.mysql_error(); exit; }

                                                $coupon = mysql_fetch_array($result);

                                               

                                                $coup_name = $coupon['coupons_name'];

                                                $coup_code = $coupon['coupons_code'];

                                                $custdiscount = $coupon['coupons_product_discount'];

                                                $coup_valid_date = date("d-m-Y", strtotime($coupon['coupons_exp_date']));

                                               

                                                                                                           

                                                $couponcodeforsms = $sms_items['order_coupon_code'];

                                                $couponcodeforsms1 = explode(", ", $sms_items['order_coupon_code']);                                                                                                   

                                                $smscount = count($couponcodeforsms1);

                                               

                                                $mobilenoforsms = $sms_items['customer_mobile'];

                                                $custnameforsms = ucwords($sms_items['customer_fname']);

                                                $company_name = $coupon['company_name'];        

                                                $company_address = $coupon['city_name'];

                                               

                                                $ch=curl_init();                                  

                                               

                                                curl_setopt($ch, CURLOPT_URL, "".SMS_SERVICE_URL."?user=".USERNAME."&password=".PASSWORD."&phone=".urlencode($mobilenoforsms)."&text=".urlencode('Hi '.$custnameforsms.', Coupon from CrackMyDeal : '.$coup_code.', '.$custdiscount.'% off on '.$coup_name.' at '.$company_name.', '.$company_address.', Valid till '.$coup_valid_date.'. T&C Apply.')."&type=t&senderid=".KEY."");

                                               

                                                curl_setopt($ch, CURLOPT_HEADER, 0);

                                                curl_exec($ch);

                                                curl_close($ch);

                                    }

                        }

 

 

----------------------------------------------------------------------------------------------------------------

 

 

The SMS which works nice:

 

Hi Paresh, Coupon from CrackMyDeal : CRACKD2014, 20% off on WebHosting (Business) at Unique InfoTech, Kamothe, Valid till 31-12-2014. T&C Apply.

 

--------------------------------------------------------------------------------------------------------------

And missing content SMS :

 

Hi Paresh, Coupon from CrackMyDeal : , % off on at , , Valid till 01-01-1970. T&C Apply.

--------------------------------------------------------------------------------------------------------------

 

Please help me to solve it.

 

Thanks and regards

Paresh

 

1402152754-pdfcoupon.pdf

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.