Skip to content

Instantly share code, notes, and snippets.

@need12648430
Last active July 11, 2021 11:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save need12648430/205c8288693ead748fed to your computer and use it in GitHub Desktop.
Save need12648430/205c8288693ead748fed to your computer and use it in GitHub Desktop.
Tiny SMS Gate Examples
<?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!
}
?>
<?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!
}
?>
<?php
$phone = $_GET["phone"]
$message = $_GET["message"];
// log to file
$file = fopen("texts.txt", "a+");
fwrite($file, $phone . ": " . $message . "\n");
fclose($file);
?>
<?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