Skip to content

Instantly share code, notes, and snippets.

@mis4s
Created September 5, 2016 13:37
Show Gist options
  • Save mis4s/8ae8c8a1583e0c58211d732d9bd76dd0 to your computer and use it in GitHub Desktop.
Save mis4s/8ae8c8a1583e0c58211d732d9bd76dd0 to your computer and use it in GitHub Desktop.
wFirma API 2 exmple request token
<?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