/** * @param string $permissions A list of comma separated permissions. * @return Gajus\Fuss\User */ function create_test_user($permissions = '') { $app = new Gajus\Fuss\App(\TEST_APP_ID, \TEST_APP_SECRET); $request = new Gajus\Fuss\Request($app, 'POST', 'app/accounts/test-users', ['permissions' => $permissions]); $test_user = $request->make(); $GLOBALS['test']['test_user'][] = $test_user; return $test_user; }
/** * @param Gajus\Fuss\AccessToken $access_token * @return null */ public function setAccessToken(\Gajus\Fuss\AccessToken $access_token) { $this->access_token = $access_token; $request = new \Gajus\Fuss\Request($this, 'GET', 'me', ['fields' => 'id']); $response = $request->make(); // @todo Check if it is user access token, as oppose to page or whatever. if ($this->id && $response['id'] !== $this->id) { throw new \Gajus\Fuss\Exception\UserException('The new access token is for a different user.'); } $this->id = $response['id']; }
/** * @dataProvider nonStringBodyParametersProvider */ public function testNonStringBodyParameters(array $restrictions) { $request = new Gajus\Fuss\Request($this->app, 'POST', 'app'); $request->setBody(['restrictions' => $restrictions]); $this->assertTrue($request->make()); $request = new Gajus\Fuss\Request($this->app, 'GET', 'app', ['fields' => 'restrictions']); $response = $request->make(); $this->assertSame($restrictions, $response['restrictions']); }
/** * Exchange code for an access token. * * @see https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.0#exchangecode * @param string $code The parameter received from the Login Dialog. * @param string $redirect_url This argument is required and must be the same as the original request_uri that you used when starting the OAuth login process. In case of FB.login, it is empty string. * @return Gajus\Fuss\AccessToken */ public static function makeFromCode(\Gajus\Fuss\App $app, $code, $redirect_url = '') { $request = new \Gajus\Fuss\Request($app, 'GET', 'oauth/access_token', ['client_id' => $app->getId(), 'client_secret' => $app->getSecret(), 'redirect_uri' => $redirect_url, 'code' => $code]); $response = $request->make(); return new \Gajus\Fuss\AccessToken($app, $response['access_token'], \Gajus\Fuss\AccessToken::TYPE_USER); }