PHP code example of mradionov / phonegap-build-api

1. Go to this page and download the library: Download mradionov/phonegap-build-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mradionov / phonegap-build-api example snippets


use PhonegapBuildApi;

// Use token

$api = new PhonegapBuildApi('authentication_token');

// Use username and password

$api = new PhonegapBuildApi('[email protected]', 'password');

// Set auth options after init

$api = new PhonegapBuildApi();

$api->setToken('authentication_token');
$api->setCredentials('[email protected]', 'password');

// Use factory

$res = PhonegapBuildApi::factory('[email protected]', 'password')->getProfile();

use PhonegapBuildApi;

$api = new PhonegapBuildApi();

$api->setAccessToken('d4f5g6');

$res = $api->getProfile();

if ($api->success()) {

  var_dump($res['email']); // '[email protected]'

} else {

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

}

$res = $api->getProfile();

$res = $api->getApplications();

$res = $api->getApplication(5);

$res = $api->getApplicationIcon(5);

$res = $api->downloadApplicationPlatform(5, PhonegapBuildApi::IOS);
$res = $api->downloadApplicationPlatform(5, PhonegapBuildApi::ANDROID);

$res = $api->getKeys();

$res = $api->getKeysPlatform(PhonegapBuildApi::IOS);
$res = $api->getKeysPlatform(PhonegapBuildApi::ANDROID);

$res = $api->getKeyPlatform(PhonegapBuildApi::IOS, 3);
$res = $api->getKeyPlatform(PhonegapBuildApi::ANDROID, 3);

$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
));

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

$res = $api->createApplicationFromFile('/path/to/archive.zip', array(
  'title' => 'Phonegap Application',
  // see docs for all options
));

$res = $api->updateApplication(5, array(
  'title' => 'Phonegap Application',
  // better use methods below or see docs for all options
));

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

$res = $api->updateApplicationFromFile(5, '/path/to/archive.zip', array(
  'title' => 'Phonegap Application',
  // see docs for all options
));

$res = $api->updateApplicationIcon(5, '/path/to/icon.png');

$res = $api->buildApplication(5, array(
  PhonegapBuildApi::IOS, PhonegapBuildApi::ANDROID
));

$res = $api->buildApplicationPlatform(5, PhonegapBuildApi::IOS);
$res = $api->buildApplicationPlatform(5, PhonegapBuildApi::ANDROID);

$res = $api->addCollaborator(5, array(
  'email' => '[email protected]',
  'role' => PhonegapBuildApi::ROLE_TESTER, // PhonegapBuildApi::ROLE_DEV
  // see docs for all options
));

$res = $api->updateCollaborator(5, 7, array(
  'role' => PhonegapBuildApi::ROLE_TESTER, // PhonegapBuildApi::ROLE_DEV
  // see docs for all options
));

$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
));

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

$res = $api->addKeyIos('Key Title', '/path/to/key.p12', '/path/to/key.mobileprovision', array(
  // see docs for all options
));

$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
));

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

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

$res = $api->deleteApplication(5);

$res = $api->deleteCollaborator(5, 7);

$res = $api->deleteKeyPlatform(PhonegapBuildApi::IOS, 3);
$res = $api->deleteKeyPlatform(PhonegapBuildApi::ANDROID, 3);