Coder Social home page Coder Social logo

php-signal's Introduction

IMPORTANT

This is no longer actively maintained. If someone is actively maintaing the fork, I will link the same here and archive this.

php-signal

php-signal is a slim PHP wrapper around signal-cli

Features:

  • Send messages to individuals, groups.
  • Link to Master Device (Smartphone)
  • Manage Groups
  • Manage Profile
  • Manage Device
  • Receive Messages (Not as Daemon)
  • Check if Number exist on Signal Server
  • Register, Verify and Unregister Number

How to Install signal-cli

Please refer official Installation Doc

Note: Please make sure to keep .so|.dylib library in same directory as the binary

Installation

composer require jigarakatidus/php-signal

Usage

require 'vendor/autoload.php';

use jigarakatidus\Signal;

$client = new Signal(
    '/Users/jigar.d/signal-cli/bin/signal-cli', // Binary Path
    '+919664*****', // Username/Number including Country Code with '+' 
    Signal::FORMAT_JSON // Format
);

// Register the Number (username)
$client->register()

// Verify the Number
$client->verify('112-360');

// Unregister the Number
$client->unregister();

// Check if number(s) exist on Signal Server
$client->getUserStatus(['+91966xxxxxxx', '+91961xxxxxxx']);

// Send Message
$client->send(['+91966xxxxxxx', '+91961xxxxxxx'], "Hi, testing from' PHP Library");

// Receive Messages - More details in DocBlock
$client->receive();

// Update Name, Avatar, etc
$client->updateProfile('Jigar D');

// Link this signal-cli as secondary device
$client->link('MacBook');

// Link other devices to this one.
// Works only when this is master
$client->addDevice('tsdevice:/?uuid=6dNLUdpVTdCV-q_eN6TJtA&pub_key=BUCL9Jq64r1yLvNeyzS0mJgMjz2u82he3B5Wr%2BtrMitx');

// List Devices
$client->listDevices();

// Remove Device, works only when this is master
$client->removeDevice(2);

// Update the account attributes on the signal server
$client->updateAccount();

// Create Group
$client->createGroup('Test', ['+91961xxxxxxx']);

// List Groups
$client->listGroups();

// Join Group
$client->joinGroup('https://signal.group/#CjQKIEBNZJkVK5IMtoQZt46O-ZIdhOqeQCwtrZQsag_3FUoIEhBrN_ht_mr6Dbe5vR-EWpVm');

// Quit Group
$client->quitGroup('usPpOsVTgDTt8JE8UKedMhYXteL2YE5WzYzMnJEp/gI=');

Output and Error

More details from command can be fetched. eg:

$client->getCommand()->getOutput();
$client->getCommand()->getError();
$client->getCommand()->getExitCode();

Testing

TODO

  • Unit Tests
  • Better handling to link to a device

License

This project uses

Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html

php-signal's People

Contributors

dminko avatar jigar-dhulla avatar kovinet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-signal's Issues

Parse `receive` responses

Would you be interested in additional methods to parse the information that comes in when the receive method is run?

I imagine https://github.com/isamert/scli must be doing some of this work, and maybe many other projects are which i am ignorant of. Would be great to build on another library and maybe in that case it would not be methods in php-signal here.

If we do have to do it all ourselves here in php-signal, these are examples of some of the types of results from the receive method we may want to parse.

Parsing the results of receive

What follows are some examples of responses to receive which we may want to understand programmatically so as to be able to respond or process automatically.

Checking if a message was received

(Received, by device not server i think, but definitely "received" not "read".)

Envelope from: “Agaric” +15082833557 (device: 2)
Timestamp: 1650860993173 (2022-04-25T04:29:53.173Z)
Server timestamps: received: 1650860993232 (2022-04-25T04:29:53.232Z) delivered: 1650861007214 (2022-04-25T04:30:07.214Z)
Sent by unidentified/sealed sender
Received a receipt message
  When: 1650860993173 (2022-04-25T04:29:53.173Z)
  Is delivery receipt
  Timestamps:
  - 1650860991942 (2022-04-25T04:29:51.942Z)

Acknowledging a reaction

Envelope from: “Agaric” +15082833557 (device: 2)
Timestamp: 1650861951271 (2022-04-25T04:45:51.271Z)
Server timestamps: received: 1650861951370 (2022-04-25T04:45:51.370Z) delivered: 1650861963571 (2022-04-25T04:46:03.571Z)
Sent by unidentified/sealed sender
Message timestamp: 1650861951271 (2022-04-25T04:45:51.271Z)
Profile key update
Reaction:
  Emoji: 👍
  Target author: “Solidarity Network” +16127129191
  Target timestamp: 1650860991942 (2022-04-25T04:29:51.942Z)
  Is remove: false

Envelope from: “Agaric” +15082833557 (device: 2)
Timestamp: 1650861963627 (2022-04-25T04:46:03.627Z)
Server timestamps: received: 1650861963919 (2022-04-25T04:46:03.919Z) delivered: 1650861963922 (2022-04-25T04:46:03.922Z)

Receiving messages

Envelope from: “Agaric” +15082833557 (device: 2)
Timestamp: 1650862095013 (2022-04-25T04:48:15.013Z)
Server timestamps: received: 1650862095141 (2022-04-25T04:48:15.141Z) delivered: 1650862108933 (2022-04-25T04:48:28.933Z)
Sent by unidentified/sealed sender
Message timestamp: 1650862095013 (2022-04-25T04:48:15.013Z)
Body: msg 1
Profile key update

Envelope from: “mlncn” +15082833557 (device: 2)
Timestamp: 1650862097429 (2022-04-25T04:48:17.429Z)
Server timestamps: received: 1650862097542 (2022-04-25T04:48:17.542Z) delivered: 1650862108933 (2022-04-25T04:48:28.933Z)
Sent by unidentified/sealed sender
Message timestamp: 1650862097429 (2022-04-25T04:48:17.429Z)
Body: msg 2
Profile key update

Envelope from: “mlncn” +15082833557 (device: 2)
Timestamp: 1650862109044 (2022-04-25T04:48:29.044Z)
Server timestamps: received: 1650862109330 (2022-04-25T04:48:29.330Z) delivered: 1650862109332 (2022-04-25T04:48:29.332Z)

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.