Coder Social home page Coder Social 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

Watchers

James Cloos avatar

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.