를 사용하여 메시지를 보내고 응답을하고 header()
는 사용자를 리디렉션 할 수 있습니다.
<?php
function send($phone, $msg)
{
$API_URL = "http://sms.xyz.com/";
$UNAME = "abc";
$PASS = "xyz";
$query = array(
'uname'=>$UNAME,
'pass'=>$PASS,
'phone'=>$phone,
'msg'=>$msg
);
$url = $API_URL . "?" . http_build_query($query);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // set the url to fetch
curl_setopt($ch, CURLOPT_HEADER, 0); // set headers (0 = no headers in result)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // type of transfer (1 = to string)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 4000); // time to wait in miliseconds
$content = curl_exec($ch); // Make the call
curl_close($ch);
echo "Response Message == ".$content; // Response message
}
// Now hit the function
send('9220022002', 'Hello world!');
// and redirect wherever you want
header("location:http://www.google.com");
// or
header("location:/something/anything");
// or
header("location:index.php");
exit(); // always use exit after using header('Location')
웹 사이트 사용자가 자격증 명을 볼 때 cURL 또는'file_get_contents' – sjagr
을 사용하십시오. – kero
대신에 filee_get_contents의 사용법을 알고 curl이 문제를 만들고 있습니다. : – Ashish