-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsms.php
executable file
·40 lines (32 loc) · 892 Bytes
/
sms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require "start.php";
require "scripts/cmdline.php";
$from = SMS_Provider_Twilio::format_number("16507993371");
//$to = SMS_Provider_Twilio::format_number("14847722224");
$to = "16505551212";
echo "Simulating SMS $from -> $to\n";
while (true)
{
$msg = readline("> ");
try
{
$url = abs_url("/sg/incoming?provider=Mock&from=".urlencode($from)
."&to=".urlencode($to)
."&msg=".urlencode($msg));
$res = file_get_contents($url);
$dom = new DOMDocument();
$dom->loadXML($res);
}
catch (ErrorException $ex)
{
continue;
}
$smses = $dom->getElementsByTagName('Sms');
for ($i = 0; $i < $smses->length; $i++)
{
$text = $smses->item($i)->textContent;
$len = strlen($text);
echo "$text\n";
echo "($len chars)\n";
}
}