[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace Balanced; 4 5 use Balanced\Resource; 6 use Balanced\Settings; 7 use \RESTful\URISpec; 8 9 /** 10 * Represents an api key. These are used to authenticate you with the api. 11 * 12 * Typically you create an initial api key: 13 * 14 * <code> 15 * print \Balanced\Settings::$api_key == null; 16 * $api_key = new \Balanced\APIKey(); 17 * $api_key = api_key->save(); 18 * $secret = $api_key->secret; 19 * print $secret; 20 * </code> 21 * 22 * Then save the returned secret (we don't store it) and configure the client 23 * to use it: 24 * 25 * <code> 26 * \Balanced\Settings::$api_key = 'my-api-key-secret'; 27 * </code> 28 * 29 * You can later add another api key if you'd like to rotate or expire old 30 * ones: 31 * 32 * <code> 33 * $api_key = new \Balanced\APIKey(); 34 * $api_key = api_key->save(); 35 * $new_secret = $api_key->secret; 36 * print $new_secret; 37 * 38 * \Balanced\Settings::$api_key = $new_secret; 39 * 40 * \Balanced\APIKey::query() 41 * ->sort(\Balanced\APIKey::f->created_at->desc()) 42 * ->first() 43 * ->delete(); 44 * </code> 45 */ 46 class APIKey extends Resource 47 { 48 protected static $_uri_spec = null; 49 50 public static function init() 51 { 52 self::$_uri_spec = new URISpec('api_keys', 'id', '/v1'); 53 self::$_registry->add(get_called_class()); 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |