2017 © Pedro Peláez
 

library phonegap-build-api

PHP library to interact with Phonegap Build API

image

mradionov/phonegap-build-api

PHP library to interact with Phonegap Build API

  • Thursday, June 2, 2016
  • by micrddrgn
  • Repository
  • 3 Watchers
  • 7 Stars
  • 1,329 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Phonegap Build API - PHP

PHP library to interact with Phonegap Build API, (*1)

Support

The latest version of Cordova (Phonegap) for the time when library was developed - 3.1.0. Contains all methods that are presented in this version of API. Anyways, it has to work with the latest versions of Cordova (Phonegap) 5+., (*2)

OS support: iOS, Android., (*3)

Requires CURL PHP extension to be installed and enabled, it will trigger a PHP error otherwise., (*4)

Install

Install via Composer from command line:, (*5)

$ composer require mradionov/phonegap-build-api

or add it to composer.json:, (*6)

{
  "require": {
    "mradionov/phonegap-build-api": "^0.1.0"
  }
}

and run, (*7)

$ composer install

Use

PhonegapBuildApi constructor accepts two arguments, second is optional. If only one argument is provided, then it has to be authentication token. If two - username and password. Otherwise, you can always provide auth params later using public methods setToken() and setCredentials(). There is also a static factory method to use API in a different way:, (*8)

use PhonegapBuildApi;

// Use token

$api = new PhonegapBuildApi('authentication_token');

// Use username and password

$api = new PhonegapBuildApi('email@example.com', 'password');

// Set auth options after init

$api = new PhonegapBuildApi();

$api->setToken('authentication_token');
$api->setCredentials('email@example.com', 'password');

// Use factory

$res = PhonegapBuildApi::factory('email@example.com', 'password')->getProfile();

Note: Authentication token mentioned above is taken from Phonegap Build account -> "Edit account" page -> "Authentication token" section., (*9)

To use access token from OAuth2 flow use a method setAccessToken():, (*10)

use PhonegapBuildApi;

$api = new PhonegapBuildApi();

$api->setAccessToken('d4f5g6');

Handle response

Each API method returns response as associative array created from JSON (if successful). You can use method success() to check whether or not last request was successful. You can use method error() to get error message, if request failed., (*11)

$res = $api->getProfile();

if ($api->success()) {

  var_dump($res['email']); // 'email@example.com'

} else {

  var_dump($api->error()); // 'Invalid email or password.'

}

API

GET /api/v1/me (docs)
$res = $api->getProfile();
GET /api/v1/apps (docs)
$res = $api->getApplications();
GET /api/v1/apps/:id (docs)
$res = $api->getApplication(5);
GET /api/v1/apps/:id/icon (docs)
$res = $api->getApplicationIcon(5);
GET /api/v1/apps/:id/:platform (docs)
$res = $api->downloadApplicationPlatform(5, PhonegapBuildApi::IOS);
$res = $api->downloadApplicationPlatform(5, PhonegapBuildApi::ANDROID);
GET /api/v1/keys (docs)
$res = $api->getKeys();
GET /api/v1/keys/:platform (docs)
$res = $api->getKeysPlatform(PhonegapBuildApi::IOS);
$res = $api->getKeysPlatform(PhonegapBuildApi::ANDROID);
GET /api/v1/keys/:platform/:id (docs)
$res = $api->getKeyPlatform(PhonegapBuildApi::IOS, 3);
$res = $api->getKeyPlatform(PhonegapBuildApi::ANDROID, 3);
POST /api/v1/apps (docs)
$res = $api->createApplication(array(
  'title' => 'Phonegap Application',
  'package' => 'com.phonegap.www',
  'version' => '0.0.1',
  'description' => 'Phonegap Application Description',
  'debug' => false,
  'keys' => array(
    'ios' => array(
      'id' => 3,
      'password' => 'key_password'
    ),
  ),
  'private' => true,
  'phonegap_version' => '3.1.0',
  'hydrates' => false,
  // better use methods below or see docs for all options
));

From remote repo (preferable):, (*12)

$res = $api->createApplicationFromRepo('https://github.com/phonegap/phonegap-start', array(
  'title' => 'Phonegap Application',
  // see docs for all options
));

From file (preferable):, (*13)

$res = $api->createApplicationFromFile('/path/to/archive.zip', array(
  'title' => 'Phonegap Application',
  // see docs for all options
));
PUT /api/v1/apps/:id (docs)
$res = $api->updateApplication(5, array(
  'title' => 'Phonegap Application',
  // better use methods below or see docs for all options
));

From remote repo (preferable):, (*14)

$res = $api->updateApplicationFromRepo(5, array(
  'title' => 'Phonegap Application',
  // see docs for all options
));

From file (preferable):, (*15)

$res = $api->updateApplicationFromFile(5, '/path/to/archive.zip', array(
  'title' => 'Phonegap Application',
  // see docs for all options
));
POST /api/v1/apps/:id/icon (docs)
$res = $api->updateApplicationIcon(5, '/path/to/icon.png');
POST /api/v1/apps/:id/build (docs)
$res = $api->buildApplication(5, array(
  PhonegapBuildApi::IOS, PhonegapBuildApi::ANDROID
));
POST /api/v1/apps/:id/build/:platform (docs)
$res = $api->buildApplicationPlatform(5, PhonegapBuildApi::IOS);
$res = $api->buildApplicationPlatform(5, PhonegapBuildApi::ANDROID);
POST /api/v1/apps/:id/collaborators (docs)
$res = $api->addCollaborator(5, array(
  'email' => 'collab@example.com',
  'role' => PhonegapBuildApi::ROLE_TESTER, // PhonegapBuildApi::ROLE_DEV
  // see docs for all options
));
PUT /api/v1/apps/:id/collaborators/:id (docs)
$res = $api->updateCollaborator(5, 7, array(
  'role' => PhonegapBuildApi::ROLE_TESTER, // PhonegapBuildApi::ROLE_DEV
  // see docs for all options
));
POST /api/v1/keys/:platform (docs)
$res = $api->addKeyPlatform(PhonegapBuildApi::IOS, array(
  // better use methods below or see docs for all options
));
$res = $api->addKeyPlatform(PhonegapBuildApi::ANDROID, array(
  // better use methods below or see docs for all options
));

Android specific (preferable):, (*16)

$res = $api->addKeyAndroid('Key Title', '/path/to/key.keystore', array(
  'alias' => 'release',
  // see docs for all options
));

iOS specific (preferable):, (*17)

$res = $api->addKeyIos('Key Title', '/path/to/key.p12', '/path/to/key.mobileprovision', array(
  // see docs for all options
));
PUT /api/v1/keys/:platform/:id (docs)
$res = $api->updateKeyPlatform(PhonegapBuildApi::IOS, 3, array(
  // better use methods below or see docs for all options
));
$res = $api->updateKeyPlatform(PhonegapBuildApi::ANDROID, 3, array(
  // better use methods below or see docs for all options
));

Android specific (preferable):, (*18)

$res = $api->updateKeyIos(3, 'key_password');

iOS specific (preferable):, (*19)

$res = $api->updateKeyAndroid(3, 'key_password', 'keystore_password');
DELETE /api/v1/apps/:id (docs)
$res = $api->deleteApplication(5);
DELETE /api/v1/apps/:id/collaborators/:id (docs)
$res = $api->deleteCollaborator(5, 7);
DELETE /api/v1/keys/:platform/:id (docs)
$res = $api->deleteKeyPlatform(PhonegapBuildApi::IOS, 3);
$res = $api->deleteKeyPlatform(PhonegapBuildApi::ANDROID, 3);

The Versions

02/06 2016

dev-master

9999999-dev

PHP library to interact with Phonegap Build API

  Sources   Download

MIT

by Michael Radionov

api php build phonegap

02/06 2016

0.2.0

0.2.0.0

PHP library to interact with Phonegap Build API

  Sources   Download

MIT

by Michael Radionov

api php build phonegap

25/11 2015

0.1.1

0.1.1.0

PHP library to interact with Phonegap Build API

  Sources   Download

MIT

by Michael Radionov

api php build phonegap

25/11 2015

0.1.0

0.1.0.0

PHP library to interact with Phonegap Build API

  Sources   Download

MIT

by Michael Radionov

api php build phonegap