Last active
March 13, 2020 17:08
-
-
Save missoxd/29fc8a77e159974df1002037b239c5ba to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Quando já temos o access_token e o token_secret. | |
* | |
* Precisamos ter a OAuth lib instalada no PHP, caso ela não esteja presente, no Ubuntu podemos instalar com: | |
* $ sudo apt install php-oauth | |
*/ | |
$url = 'https://<mage-host>/api/rest/'; | |
$consumerKey = '<consumer-key>'; | |
$consumerSecret = '<consumer-secret>'; | |
$token = '<token>'; | |
$tokenSecret = '<token-secret>'; | |
try { | |
$oauth = new \OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION); | |
$oauth->enableDebug(); | |
$oauth->setToken($token, $tokenSecret); | |
$resource = $url . 'orders'; | |
$oauth->fetch($resource, [], 'GET', ['Content-Type' => 'application/json', 'Accept' => 'application/json']); | |
$response = json_decode($oauth->getLastResponse()); | |
print_r($response); | |
} catch (\OAuthException $e) { | |
print_r($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment