ch = curl_init();
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
}
public function getNumbers($prefix) {
curl_setopt($this->ch, CURLOPT_URL, self::PROVIDER);
$res = curl_exec($this->ch);
$html = new simple_html_dom();
$html->load($res);
$items = $html->find('option');
$numbers = [];
foreach($items as $num) {
if(preg_match('/^\+'.$prefix.'/i', $num->plaintext)) {
preg_match('/^\+(\d+)/', $num->plaintext, $phone);
$numbers[] = ['phone' => $phone[1], 'id' => $num->value];
}
}
return $numbers;
}
public function getSms($phone_id) {
curl_setopt_array($this->ch, [
CURLOPT_URL => self::PROVIDER . '/json.php',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'ajax' => '1',
'number' => $phone_id
]
]);
$res = curl_exec($this->ch);
$html = new simple_html_dom();
$html->load($res);
$items = $html->find('tr');
$last_sms = [];
foreach($items as $sms) {
$last_sms[] = ['from' => $sms->children(0)->plaintext, 'text' => $sms->children(1)->plaintext];
}
print_r($last_sms);
}
}