Giter VIP home page Giter VIP logo

gammu-php's Introduction

gammu-php

A php API that enables you to send and receive SMS via a simple REST API

Find more about how to use it here:

Prerequisites

  • A USB modem dongle you can put into modem mode
  • gammu and gammu-smsd
  • php and php-json

From within the directory where the two php files (send.php and get.php) are stored, run php -S 0.0.0.0:8080 which will serve the two files to anyone on the network on port 8080.

Sending SMS

Just call http://ip.of.your.pi/send.php?phone=07921XXXXXX&text=Testmessage from curl or a browser and it will return a JSON object indicating if it failed (status:error), or succeeded (status:ok)

The variables phone and text are mandator and can be sent via GET or POST (both POST variable or JSON body supported)

{
  "status": "ok",
  "log": "2021-12-04 15:43:39\ngammu-smsd-inject TEXT 07921XXXXXX -unicode -text 'Testmessage'\ngammu-smsd-inject[2669]: Warning: No PIN code in /etc/gammu-smsdrc file\ngammu-smsd-inject[2669]: Created outbox message OUTC20211204_164340_00_07921XXXXXX_sms0.smsbackup\nWritten message with ID /var/spool/gammu/outbox/OUTC20211204_164340_00_07921XXXXXX_sms0.smsbackup\n\n\n"
}

Receiving SMS with the API

Call http://ip.of.your.pi:8080/get.php

And it will return you all messages also in a JSON object

curl -s http://ip.of.your.pi:8080/get.php
[
  {
    "id": "f0a7789a657bb34e43c17c8e64609c48",
    "timestamp": 1638636342,
    "year": "2021",
    "month": "12",
    "day": "04",
    "time": "16:45",
    "test": "04.12.2021 16:45:42",
    "sender": "+437921XXXXXX",
    "message": "Hello bob!"
  },
  {
    "id": "c358d0a4e5868c1d7d2eedab181eddd6",
    "timestamp": 1638636414,
    "year": "2021",
    "month": "12",
    "day": "04",
    "time": "16:46",
    "test": "04.12.2021 16:46:54",
    "sender": "+437921XXXXXX",
    "message": "Hello "
  }
]

gammu-php's People

Contributors

geek-at avatar ishtiyaq-td avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gammu-php's Issues

Problem with letters with accent

The form fields are passed through CURL to the configured Raspberry Pi. Before passing the SMS text field, I process it by replacing spaces with %20.

The issue arises when the text contains accented letters such as à,è,ò,ì,ù (quite common in Italian). During the transfer, these letters were getting eliminated. To address this, I applied URL encoding to the text before sending and made some modifications to the send.php file you provided.

Number format

Good day

2 questions

First, not send SMS if phone=+1234567....
Second, not send cyrillic

send.php contains remote execution vulnerability

The input-value for $rec is not sanitized and can thus be used to inject remote code execution vulnerabilities on the server hosting this API.

This repo should have a warning that it's currently not security hardened and never to recommend usage on untrusted networks or networks with untrusted devices 😁

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.