Skip to content
dgmyrek edited this page Mar 21, 2018 · 4 revisions

Create a file in the project root called cli.php and add this. Be sure to update your_access_token_here.

<?php

header('Content-Type: text/html; charset=UTF-8');

// include the SparkAPI core which autoloads other classes as necessary
require_once("lib/Core.php");

$api = new SparkAPI_Bearer("your_access_token_here");

$api->SetApplicationName("PHP-CLI-Example");

$api->api_base = "sparkapi.com";

Then launch php in interactive mode and load this file.

$ php -a -d auto_prepend_file=cli.php

You can now call any of the functions defined in lib/Core.php on $api.

php > $api->GetListings();