2011-07-10 54 views
0

我想通過短信發送用戶憑據後registration.The網關可以使用GET方法來訪問我想它,以便儘快融入我的registration_process.php文件因爲細節以db輸入,短信應該被傳送。通過HTTP API.So短信網關和API在PHP

GET方法類似於

http://gatewayprovider?user=<username>&password=<password>&msg=<$my msg>&no=<$receiver no> 

所以,我怎麼能叫這個網址沒有任何知識的用戶。這是一種安全的方式

謝謝。

+0

如果您使用一些虛擬主機服務託管您的網站。確保主機提供商允許您向其他服務器發送請求。 – balki

+1

如果他們不 - 更換主機。 – Quentin

回答

2

你行你cURL,如果已安裝並在web服務器上啓用。

稍加修改example from php.net

$url = "http://gatewayprovider?user=".$username."&password=".$password."&msg=".$myMsg."&no=".$receiver_no; 

// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// grab URL and pass it to the browser 
curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 

當你說

這是一種安全的方式

我很難相信以明文形式發送的數據作爲HTTP GET請求安全。

的數據將invisble用戶,但任何人都嗅探你的數據可以讀取它。網關是否提供https?

也使用GET發送數據,而不是POST方法是不安全的,因爲請求url將在日誌中可見,並考慮防火牆等。這當然是從您的服務器到短信網關的路線。

如果你的短信網關支持它,POST + HTTPS將是最好的選擇。 cURL也是在這裏使用的理想選擇。

如果你沒有安裝捲曲,你可以使用wget,通過調用一個shell腳本。

0

有很多方法可以從PHP發出HTTP請求。 cURL是一個受歡迎的。

+0

是不是可以有一個簡單的解決方案,如php頭重定向,但安全嗎? – Ajay

+1

cURL **是一個簡單的解決方案。 – Quentin

0

你也可以使用

<?php 
$url = "http://gatewayprovider?user=<username>&password=<password>&msg=<$my msg>&no=<$receiver no>"; 
$sendrequest = file_get_contents($url); 
?> 

就是這樣。