sympla/revolution-bar

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

Sdk para integração SDK RdStation

0.0.8 2020-02-10 20:11 UTC

This package is not auto-updated.

Last update: 2020-04-06 20:54:28 UTC


README

PHP Wrapper to send contact and authentication and authorization to RDStation

Instaling

composer require sympla/revolution-bar

Usage

Authentication

get url to authentication on RDStation plataform

require "vendor/autoload.php";

$authentication = new RDStation\Services\Authentication("YOUR_CLIENT_ID", "YOUR_URL_CALLBACK");
$authentication->getUrlAuthentication();

Authorization

get authorization data for send contact to rdstation

require "vendor/autoload.php";

$authorization = new RDStation\Services\Authorization("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "CODE_RDSTATION");
$authorizationResponse = $authorization->execute();
var_export($authorizationResponse->getAccessToken());
var_export($authorizationResponse->getExpireIn());
var_export($authorizationResponse->getRefreshToken());

Refresh Token

Refreshing an expired token

require "vendor/autoload.php";

$refreshToken = new RDStation\Services\RefreshToken("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "REFRESH_TOKEN");
$refreshTokenResponse = $refreshToken->execute();
var_export($refreshTokenResponse->getAccessToken());
var_export($refreshTokenResponse->getExpireIn());
var_export($refreshTokenResponse->getRefreshToken());

Send Contact

With an UPSERT like behavior, this endpoint is capable of both updating the properties of a Contact or creating a new Contact. Whatever is used as an identifier cannot appear in the request payload as a field. This will result in a BAD_REQUEST error.

require "vendor/autoload.php";

$contactIdentifier = RDStation\Request\ContactIdentifier::EMAIL;

$contactRequest = new RDStation\Request\ContactRequest(ContactIdentifier::EMAIL, [
    "YOUR_CUSTOMER_FIELD"   => "VALUE",   
    "YOUR_CUSTOMER_FIELD_2" => "VALUE",
]);

$contactRequest->setEmail("email@email.com");
$contactRequest->setName("NAME'S LEAD");
$contactRequest->setBio("BIO");
$contactRequest->setCity("BELO HORIZONTE");
$contactRequest->setCountry("BRASIL");
$contactRequest->setFacebook("FACEBOOK_LEAD");
$contactRequest->setJobTitle("JOB_TITLE");
$contactRequest->setLinkedin("LINKDEDIN LEAD");
$contactRequest->setMobilePhone("(31)99999-9999");
$contactRequest->setPersonalPhone("(31)99999-9999");
$contactRequest->setState("MG");
$contactRequest->setWebsite("https://lead_website.com");


$contact = new RDStation\Services\Contact($contactRequest, "YOUR_ACCESS_TOKEN");
var_export($contact->save());

Revoking Access Token

Client access with OAuth authentication type can be revoked whenever needed. This can be done using access_token or refresh_token.

$revokingAccess = new \RDStation\Services\RevokingAccess("YOUR_ACCESS_TOKEN");
var_export($revokingAccess->revoke());

Revoking refresh token

$revokingAccess = new \RDStation\Services\RevokingAccess("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", "refresh_token");
var_export($revokingAccess->revoke());