Created
September 5, 2016 13:37
-
-
Save mis4s/8ae8c8a1583e0c58211d732d9bd76dd0 to your computer and use it in GitHub Desktop.
wFirma API 2 exmple request token
This file contains hidden or 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
<?php | |
define('SCOPE', 'invoices-read,invoices-write,contractors-write,goods-write,goods-read'); | |
define('APP_URL', 'your-app.dev'); | |
function requestToken() { | |
$OAuth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_SIG_METHOD_PLAINTEXT); | |
try { | |
$tokenInfo = $OAuth->getRequestToken('https://wfirma.pl/oauth/requestToken?' . | |
'oauth_callback=http://'.APP_URL.'/users/accessToken&scope=' . SCOPE, | |
'', | |
OAUTH_HTTP_METHOD_GET | |
); | |
$_SESSION['oauthSecret'] = $tokenInfo['oauth_token_secret']; | |
header('Location: https://wfirma.pl/oauth/authorize?'. | |
'oauth_token='.$tokenInfo['oauth_token']); | |
} catch(OAuthException $E) { | |
// Wystąpił błąd podczas autoryzacji. | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment