2015-12-20 4 views
5

भेजें मेरे पास एक ऐसा एप्लिकेशन है जो इसके अंदर एक एसएमएस एपीआई का निर्माण और कार्यान्वित कर रहा है, लेकिन यह कुछ संख्याओं में भेजता है, जब मैं डेटाबेस से सभी का चयन करता हूं और भेजता हूं, लगभग 1100 नंबर भेजें, लेकिन यह कुछ भी नहीं करता है।यूआरएल में बहुत से फोन नंबरों को पास करना असफल रहा - एसएमएस एपीआई

मुझे लगा कि यह यूआरएल की लंबाई के कारण भेज नहीं रहा था क्योंकि संख्याएं पारित की गईं क्योंकि मैंने संख्याओं को प्रतिबिंबित किया और उन्हें टेक्स्टरी में कॉपी किया जो पहले भेज रहा था।

मैंने संख्या को सौ से पचास तक भी घटा दिया, फिर भी उसने कोई त्रुटि नहीं फेंक दी लेकिन मुझे नहीं भेजा, मैं इसे कैसे ठीक करूं।

मैं अपने प्रपत्र प्रस्तुत करने के लिए एक प्राप्त विधि का इस्तेमाल किया नीचे

$phone_group_total = $phone_numbers.", ".$send_it.", ".$selected_staffs; 
    function httpRequest($fields, $sendpage){ 
    $curl = curl_init($sendpage); 
    curl_setopt($curl, CURLOPT_POST, true); 
    curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    $result = curl_exec($curl); 
    curl_close($curl); 

    $sendpage ="http://smsexperience.com/components/com_spc/smsapi.php?"; 
    $sendsms ="username=user&password=pass"; 
    $sendsms .="&sender=$sender_id"; 
    $sendsms .="&recipient=".$phone_group_total; 
    $sendsms .="&message=$message"; 
    httpRequest($sendsms, $sendpage); 

भेजने के लिए मेरी नमूना कोड देखें, मैं पद उपयोग करने की कोशिश और मेरे संदेश भेजने नहीं थे। मैं इसे कैसे ठीक करूं और बड़ी संख्या में सेट भेजूं। धन्यवाद।

+0

यूआरएल 2000 अक्षरों तक सीमित है, जो बताता है कि आप यूआरएल क्यों छोटा कर दिया गया है। आपको 'POST' का उपयोग करने की आवश्यकता होगी। 'POST' क्यों काम नहीं कर रहा है, इस पर सहायता प्राप्त करने के लिए, आपको वह कोड दिखाना होगा जिसका आप उपयोग कर रहे थे। नमूना कोड में –

+0

फ़ंक्शन ठीक से बंद नहीं है। प्रश्न पोस्ट करते समय – trincot

+0

फ़ंक्शन को बंद करने से चूक गया, पोस्ट के लिए उपयोग कर रहा कोड निम्नानुसार है; – optimalresource

उत्तर

0
if(isset($_POST['send_sms'])) 
    { 
    $sender_id = mysql_real_escape_string($_POST['sender_id']); 
    $phone_numbers = mysql_real_escape_string($_POST['phone_numbers']); 
    $message = ($_POST['message']); 
    $client_phone = ($_POST['client_phone']); 
    $employee_phone = ($_POST['employee_phone']); 
    $tailor_phone = ($_POST['tailor_phone']); 

    if($client_phone!="") 
    { 
    $sql = "SELECT mobile_phone FROM personal_details"; 
    $res = mysql_query($sql) or die(mysql_error()); 
    $recipients = array(); 

    while($row = mysql_fetch_array($res)) { 
    $recipients[] = $row['mobile_phone']; 
    } 

    $send_it = implode(', ', $recipients); 

    } 

    if($employee_phone!="") 
{ 
    $sql1 = "SELECT mobile_phone FROM employee_db"; 
    $res1 = mysql_query($sql1) or die(mysql_error()); 
$recipients1 = array(); 

    while($row1 = mysql_fetch_array($res1)) { 
    $recipients1[] = $row1['mobile_phone']; 
    } 

    $send_it1 = implode(', ', $recipients1); 
    } 

    if($tailor_phone!="") 
    { 
    $sql2 = "SELECT mobile_phone FROM employee_db WHERE department='Tailors'"; 
    $res2 = mysql_query($sql2) or die(mysql_error()); 
    $recipients2 = array(); 

while($row2 = mysql_fetch_array($res2)) { 
$recipients2[] = $row2['mobile_phone']; 
} 

$send_it2 = implode(', ', $recipients2); 
} 

    if($tailor_phone !="" && $employee_phone!="") 
{$selected_staffs = $send_it1;}else if($tailor_phone=='tailors' &&  $employee_phone=="") 
{$selected_staffs = $send_it2;}else if($tailor_phone=="" &&  $employee_phone=='employees') 
{$selected_staffs = $send_it1;} 

if($_POST['phone_numbers']=="") 
{ 
$phone_group_total = $send_it.", ".$selected_staffs; 
}else{ 
$phone_group_total =  $phone_numbers.", ".$send_it.", ".$selected_staffs;}  
function httpRequest  ($fields, $sendpage){ 
$curl = curl_init($sendpage); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($curl); 
curl_close($curl); 
} 

    $sendpage ="http://smsexperience.com/components/com_spc/smsapi.php?"; 
    $sendsms ="username=user&password=pass"; 
    $sendsms .="&sender=$sender_id"; 
    $sendsms .="&recipient=".$phone_group_total;   $sendsms .="&message=$message"; 
    httpRequest($sendsms, $sendpage); } 

यह मेरे कोड के लिए पोस्ट नमूना है, और यह चर भेजने योग्य भी नहीं देखता है और इसी तरह। लेकिन गेट विधि सबकुछ देखती है और ठीक काम करती है।

0

अब मैं एक पोस्ट विधि का उपयोग करके और अगर ($ _ सर्वर ['REQUEST_METHOD' के साथ (ifet ($ _ POST ['send_sms']) को बदलकर यूआरएल में बहुत से तर्क पारित करने की समस्या को हल करने में सक्षम था। ] == "पोस्ट") और जिसने फॉर्म वैल्यू को सही तरीके से सबमिट करना शुरू किया और मेरे एसएमएस भेजता है। मैंने यह भी देखा कि संख्याओं को अलग करने के लिए संख्या और एक नई लाइन का उपयोग किया जाता है, mysql_real_escape_string लाइनों को अक्षरों में परिवर्तित करता है और संख्या एसएमएस एपीआई में सबमिट नहीं होती है, इसलिए समाधान mysql_real_escape_string कमांड को निकालना था और एसएमएस संख्याओं के लंबे सेट के लिए जादू की तरह काम किया।

संबंधित मुद्दे