0
電話番号を収集し、URLを介して別のスクリプトに送信するスクリプトがあります。このスクリプトは米国の数値には問題ありませんが、英国の数値ではうまく機能しません。どんな助けもありがとう。米国の電話番号のみを使用して米国と国際番号または英国番号を使用するスクリプトを変更する方法
これは私が使用しているコードです。 philnashが指摘したように
<?php
session_start();
function post_to_sms($url,$post_string)
{
// post form to SMS API
$curl_result=$curl_err='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
// note - set HOST where your API resides
curl_setopt($ch, CURLOPT_HTTPHEADER, array("POST /cgi-bin/webscr HTTP/1.1",
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: " . strlen($post_string),
"Host: yourdomain.com",
"Connection: close"));
curl_setopt($ch, CURLOPT_HEADER , 0);
curl_setopt($ch, CURLINFO_HEADER_OUT , 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$curl_result = @curl_exec($ch);
// 2 lines of debug (comment for production)
// print_r(curl_getinfo($ch));
// echo "<br /> error = " . $curl_err = curl_error($ch);
curl_close($ch);
return $curl_result;
} // end of CURL function
// URL for your SMS API
$url = "yourdomain.com/sms/sms_controlling.php";
if(isset($_REQUEST['telNumber']))
{
if(is_numeric($_REQUEST['telNumber']) && ($_REQUEST['telNumber'] > '1000000000') && ($_REQUEST['telNumber'] < '9999999999'))
{
// create array of form variables
// 'From' is input - 'To' and 'Body' is hard-coded
$post_data['From'] = $_REQUEST['telNumber'];
$post_data['To'] = "%2b17204447777"; //Enter Twilio Phone number
$post_data['Body'] = "keyword Here"; //Enter The Keyword to your SMS Campaign.
foreach ($post_data as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
post_to_sms($url, $post_string);
} else {
$_SESSION['errmessage'] = "Sorry. All 10 Digits of Phone Number (incl Area Code) are required.";
}
}
?>
これらの条件を使用している理由を教えてください。 '$ _REQUEST ['telNumber']> '1000000000''と '$ _REQUEST ['telNumber'] <'9999999999'' – Titanoboa
国際番号の場合は、国コード接頭辞を使用していることを確認する必要があります44)。あなたはそれをやっていますか?それはTitanoboaが尋ねた条件を乱していますか? – philnash
こんにちは、私はプログラマーではなく、これが米国で働く方法を理解する唯一の方法です。私は%2b1を+44に変更し、情報を正しく送信しますが、アプリケーションがURL文字列を受け取ったときにtwilioに送信しません。だから、それは私のアプリケーションの中にあって、フォームの中にあるべきではありません。応答していただきありがとうございます。 – MichaelP