unificationengine/ue-php-sdk

There is no license information available for the latest version (1.5.1) of this package.

UnificationEngine PHP SDK

1.5.1 2016-03-26 13:00 UTC

This package is not auto-updated.

Last update: 2024-05-03 15:42:05 UTC


README

A UnificationEngine client SDK for PHP

Installation Using Composer/Packagist

$ composer require unificationengine/ue-php-sdk

Usage

use UnificationEngine\Models\UEApp;
$app = new UEApp("APP_KEY","APP_SECRET");

Creating User

use UnificationEngine\Models\UEApp;
use UnificationEngine\Models\UEUser;

//Use our app
$app = new UEApp("APP_KEY","APP_SECRET");

//Creating a new user
$user = $app->create_user();

//Using existing user using key and secret
$user = new UEUser("USER_KEY","USER_SECRET");

//Using existing user using it's uri
$user = new UEUser("user://USER_KEY:USER_SECRET@");

Listing Users

$users = $app->list_users();

note: listed users does not have the user_secret listed for security reasons. So, you cant use a user from the list unless you have saved it's key somewhere

Deleting User

$user = $app->create_user();
$app->delete_user($user) //true

Adding a connection to a user

$connection = $user->add_connection("connection_name", "service", "service_access_token", $optional_params);
//connection is an instance of UEConnection
  • connection_name must be unique per connection.
  • service must be the scheme of the connector from the developer portal
  • service_access_token has to be valid and working from the provider side
  • $optional_params should be an array with "key", "value" pair

Listing User connections

$connections = $user->list_connections()
// connections is an array of UEConnection objects

Removing a User Connection

$user->remove_connection($connection_name) //true | false

Testing a connection

//return true if working, false otherwise
$user->test_connection($service_url) //eg: facebook://accesstoken@facebook.com

Sending a message using a connection

$app  = new UEApp("APP_KEY","APP_SECRET");

//Create a new user
$user = $app->create_user();


//Or use an existing user
$user = new UEUser("USER_KEY","USER_SECRET");


//Add a connection. (throws an error if the connection is not added)
$connection = $user->add_connection("FB","facebook","FACEBOOK_ACCESS_TOKEN");
//                                    |       |
// Connection Name  ------------------+       |
// Connector Scheme  -------------------------+



//Message Options
$options = array(
    "receivers" => array(
        array(
            "name"=>"Page",
            "id"=>"283031198486599"
        ),
        array(
            "name"=> "Me"
        )
    ),
    "message"=>array(
        "subject"=>"test",
        "body"=> "ABC",
        "image"=>"http://politibits.blogs.tuscaloosanews.com/files/2010/07/sanford_big_dummy_navy_shirt.jpg",
        "link"=>array(
            "uri"=> "http://google.com",
            "description"=> "link desc",
            "title"=>"link title"
        )
    )
);



//Send the message and get their uris
$uris = $connection->send_message($options);

print_r($uris);