我想使用codeigniter中的第三方API密钥将SMS发送给用户。为此,我使用了file_get_content()
但是当文件运行时,它需要更多的执行时间并且在显示空白页面之后。
我也使用CURL但在codeignator中使用相同的错误。
此代码在codeigniter中仅运行另一个PHP脚本错误 按照我的代码:
$to = "thisisprashantkumbhar";
$username ='puretechnology';
$numbers = '9326447272';
$messagenew=rawurlencode($to);
$apikey = 'gdfgrte5-er54-h57f-4rgt-0a7215d15abc';
$url = "http://sms1.businesslead.co.in/sendSMS?username=$username&message=$messagenew&sendername=CMISAM&smstype=TRANS&numbers=$numbers&apikey=$apikey";
$response = file_get_contents($url);
return $response;
答案 0 :(得分:0)
Dictionary
答案 1 :(得分:0)
回显$ url,它会显示完整的url,然后执行url,你会收到错误。例如无效密钥也会检查您的详细信息。
答案 2 :(得分:-1)
//Your params
$to = "to";
$username ='username';
$numbers = '9999999999';
$messagenew=rawurlencode($to);
$apikey = 'yourkey';
//your params
$curl = curl_init();
//pass api url in CURLOPT_URL below which you want execute and get
responce
curl_setopt_array($curl, array(
CURLOPT_URL => "http://sms1.businesslead.co.in/sendSMS?username=$username&message=$messagenew&sendername=CMISAM&smstype=TRANS&numbers=$numbers&apikey=$apikey",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err; // it will reflect error if any
} else {
echo $response;//you will get response
}