Пример #1
0
 public function testEmails()
 {
     $user = new User();
     $this->assertInstanceOf('GitHub\\API\\User\\Email', $user->emails());
 }
Пример #2
0
use GitHub\API\User\User;
use GitHub\API\AuthenticationException;
// Lets access the User API
$user = new User();
/**
 * Perform operations that require no authentication
 */
// Get details for user 'dsyph3r'
var_dump($user->get('dsyph3r'));
// Get users 'dsyph3r' is following
var_dump($user->following('dsyph3r'));
/**
 * Perform operations that require authentication
 */
// Set user credentials and login
$user->setCredentials(new Authentication\Basic('username', 'password'));
$user->login();
try {
    // Check if your following user
    var_dump($user->isFollowing("octocat"));
    // Update some user details
    var_dump($user->update(array('location' => 'Wales, United Kingdom')));
    // Get all emails for user
    var_dump($user->emails()->all());
    // Add key for user
    var_dump($user->keys()->create("New Key", "ssh-rsa CCC"));
} catch (AuthenticationException $exception) {
    echo $exception->getMessage();
}
// Finally lets logout
$user->logout();