forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the username and password authentication method for authentica…
…tion.
- Loading branch information
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
examples/authentication/api/session_token_with_username_and_password.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
require_once '../../../vendor/autoload.php'; | ||
require_once '../../../apikey.php'; | ||
|
||
$token = new \Tmdb\ApiToken(TMDB_API_KEY); | ||
$client = new \Tmdb\Client($token); | ||
|
||
$requestToken = new \Tmdb\RequestToken(TMDB_REQUEST_TOKEN); | ||
|
||
$validatedRequestToken = $client->getAuthenticationApi()->validateRequestTokenWithLogin( | ||
$requestToken, | ||
TMDB_USERNAME, | ||
TMDB_PASSWORD | ||
); | ||
|
||
$sessionToken = $client->getAuthenticationApi()->getNewSession($validatedRequestToken); | ||
|
||
var_dump($sessionToken); |
31 changes: 31 additions & 0 deletions
31
examples/authentication/model/session_token_with_username_and_password.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
require_once '../../../vendor/autoload.php'; | ||
require_once '../../../apikey.php'; | ||
|
||
$token = new \Tmdb\ApiToken(TMDB_API_KEY); | ||
$client = new \Tmdb\Client($token); | ||
|
||
$client->setLogging(true, '/www/dev/php-tmdb-api/tmdb.log'); | ||
|
||
$requestToken = new \Tmdb\RequestToken(TMDB_REQUEST_TOKEN); | ||
|
||
$authenticationRepository = new \Tmdb\Repository\AuthenticationRepository($client); | ||
|
||
$sessionToken = $authenticationRepository->getSessionTokenWithLogin( | ||
$requestToken, | ||
TMDB_USERNAME, | ||
TMDB_PASSWORD | ||
); | ||
|
||
var_dump($sessionToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters