Giter VIP home page Giter VIP logo

ctm-php's Introduction

Call Tracking Metrics PHP Library

Authentication

Authentication to CTM Service works by sending a request to retrieve an access token. Then each request will include the access token.

The access token is short lived and grants you access to specific set of accounts generally if you have a multi access account and use agency level API keys it will give you access to all the account's within your agency. If you have a single access account the API keys will only grant you access to that one account.

All API requests use an auth token, that has an associated account id. To change the target account, change the id on the auth token.

Example Usage

// include the library
include "lib/ctm.php";

// authenticate to get an access token
$auth_token = AuthToken::authorize($_ENV["CTM_API_KEY"],$_ENV["CTM_API_SECRET"]);
if ($auth_token) {
  echo "auth_token: {$auth_token->token}\n";
} else {
  echo "invalid credentials\n";
}

// get an existing number by ID given a valid auth token
$number = Number::get($auth_token, 42);

// update the number's name
$number->name = "test";
$number->save();

// find new numbers to purchase
$numbers_to_buy = Number::search($auth_token, "410");
var_dump($numbers_to_buy[0]);

// purchase the first number in the result list
$number = Number::buy($auth_token, $numbers_to_buy[0]->number);
var_dump($number);

// assign a receiving number to the newly purchased number
$rnid = $number->addReceivingNumber("+18889994444");
var_dump($rnid);

// assign a tracking source - e.g. a name and set of conditions that define when a website visitor should see this number
$number->setSource("test", "google.com", "gclid=.+", 88);

// remove a receiving number from this number
//$number->removeReceivingNumber($rnid);

// release the number
$number->release();

// get a paginated list of numbers available to the current account
$numbers = Number::list_numbers($auth_token);
var_dump($numbers);

// change account based on access
$auth_token->account_id=xxxx // where xxxx is another account id within your available accounts

ctm-php's People

Contributors

taf2 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.