Last active
July 11, 2021 11:32
-
-
Save need12648430/205c8288693ead748fed to your computer and use it in GitHub Desktop.
Tiny SMS Gate Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// just for the record | |
$phone_ip = "10.0.0.2"; | |
$phone_port = 8080; | |
$phone_page = "/send"; | |
// to be clear, this is set in the app preferences | |
// you can turn off password protection, but i wouldn't suggest it | |
$tinysmsgate_password = "password"; | |
// where we'll be posting to | |
$url = "http://" . $phone_ip . ":" . $phone_port . $phone_page; | |
// what we'll be posting | |
$phone = "0005551234"; | |
$message = "Hello phone, from PHP."; | |
$data = array("phone" => $phone, "message" => $message, "password" => $tinysmsgate_password); | |
// GET, and read result | |
$result = file_get_contents($url . "?" . http_build_query($data)); | |
if(strpos($result, "Sent") !== false) { | |
// sent! | |
} else { | |
// not sent! | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// just for the record | |
$phone_ip = "10.0.0.2"; | |
$phone_port = 8080; | |
$phone_page = "/send"; | |
// to be clear, this is set in the app preferences | |
// you can turn off password protection, but i wouldn't suggest it | |
$tinysmsgate_password = "password"; | |
// where we'll be posting to | |
$url = "http://" . $phone_ip . ":" . $phone_port . $phone_page; | |
// what we'll be posting | |
$phone = "0005551234"; | |
$message = "Hello phone, from PHP."; | |
$data = array("phone" => $phone, "message" => $message, "password" => $tinysmsgate_password); | |
// set up our options | |
$options = array( | |
"method": "POST", | |
"header": "Content-type: application/x-www-form-urlencoded\r\n", | |
"content": http_build_query($data), | |
); | |
$context = stream_create_context($options); | |
// POST, and read result | |
$result = file_get_contents($url, false, $context); | |
if(strpos($result, "Sent") !== false) { | |
// sent! | |
} else { | |
// not sent! | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$phone = $_GET["phone"] | |
$message = $_GET["message"]; | |
// log to file | |
$file = fopen("texts.txt", "a+"); | |
fwrite($file, $phone . ": " . $message . "\n"); | |
fclose($file); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$phone = $_POST["phone"] | |
$message = $_POST["message"]; | |
// log to file | |
$file = fopen("texts.txt", "a+"); | |
fwrite($file, $phone . ": " . $message . "\n"); | |
fclose($file); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment