我正在尝试使用API发送短信.它每秒发送几乎一条SMS但我想在一秒内使用PHP中的多线程/ pthreads发送多条SMS.怎么可能或者我怎样才能至少从我的端到异步发送多个SMS请求到API服务器.
//Threads Class
class MThread extends Thread {
public $data;
public $result;
public function __construct($data){
$this->data = $data;
}
public function run() {
foreach($this->data as $dt_res){
// Send the POST request with cURL
$ch = curl_init("http://www.example.com");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dt_res['to']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$this->result = $http_code;
/**/
}
}
}
// $_POST['data'] has multi arrays
$request = new MThread($_POST['data']);
if ($request->start()) {
$request->join();
print_r($request->result);
}
Run Code Online (Sandbox Code Playgroud)
任何想法将不胜感激.
我已经安装了poedit并通过它运行我的文件,它为它们创建了.po和.mo文件.但我有一个问题,加载和使用这些文件来翻译我的文本.我不知道如何加载或打开翻译的文件并显示翻译的内容.任何人都可以帮我这个.我尝试了所有可能的来源,但没有成功.