Пример #1
0
 public function testGetUnauthenticated()
 {
     $transportMock = $this->getTransportMock();
     $transportMock->expects($this->once())->method('send')->will($this->returnValue($this->getResultUnauthorized()));
     $user = new User($transportMock);
     $this->setExpectedException('GitHub\\API\\AuthenticationException');
     // Try without authentication
     $result = $user->get();
 }
Пример #2
0
 * @link http://symfony.com/doc/current/cookbook/tools/autoloader.html
 */
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
// Register the location of the GitHub namespace
$loader->registerNamespaces(array('Buzz' => __DIR__ . '/../lib/vendor/Buzz/lib', 'GitHub' => __DIR__ . '/../lib'));
$loader->register();
use GitHub\API\Authentication;
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());