cURL 功能不起作用 [英] cURL function not working
问题描述
我正在尝试从网站发送批量文本消息..所以我使用 api.. 我已经创建了 $sendString
变量到确切的 url 以使用 api.. 但是对于cURL 函数不适用于此特定 URL 的某些原因...
I'm trying to send bulk text messages from a website.. so im using an api.. i have created the $sendString
variable to the exact url to use the api.. but for some reason the cURL function is not working for this particular URL...
我尝试使用此 API 的另一个函数来检查我的信用余额并且它有效...我什至尝试将 $sendString
变量手动粘贴到链接框中并且它起作用了!所以我知道 cURL 和 api 都可以工作,但只是不能从网站发送我的文本......有什么想法吗?
I tried using another function with this api to check my credit balance and it works... i even tried pasting the $sendString
variable manually into the link box and it worked! So I know that cURL and the api are both working, but just not for sending out my texts from the website... any ideas?
//Create a new cURL resource
$ch = curl_init();
//Set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "$sendString");
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);
推荐答案
使用 curl_setopt_array() 用于解析所有 url 字符串
像这样:
Use curl_setopt_array() for parse all string of url
Like this:
$curl_handle = curl_init();
$options = array
(
CURLOPT_URL=>$url,
CURLOPT_HEADER=>true,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_FOLLOWLOCATION=>true,
CURLOPT_USERAGENT=>$browser_id
);
curl_setopt_array($curl_handle,$options);
$server_output = curl_exec($curl_handle);
curl_close($curl_handle);
var_dump($server_output)
这篇关于cURL 功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!