mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2024-11-23 19:00:50 +00:00
Updating oauth.php file to match the new base api
This commit is contained in:
parent
13fadfe9ae
commit
97e0a56b65
@ -1,23 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* A very compact and simple Memsource API library
|
* A very compact and simple Memsource API library
|
||||||
*
|
*
|
||||||
* @author Bruno Fontes <developer@brunofontes.net>
|
* @author Bruno Fontes <developer@brunofontes.net>
|
||||||
* @link https://github.com/brunofontes
|
* @link https://github.com/brunofontes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace BrunoFontes\Memsource;
|
namespace BrunoFontes\Memsource;
|
||||||
|
|
||||||
class Oauth extends \BrunoFontes\Memsource
|
class Oauth extends \BrunoFontes\Memsource\FetchApi
|
||||||
{
|
{
|
||||||
private $_url = '/oauth';
|
private $_url = '/oauth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL to generate the Authorization Code from Memsource
|
* Get the URL to generate the Authorization Code from Memsource
|
||||||
*
|
*
|
||||||
* @param string $client_id Memsource client ID
|
* @param string $client_id Memsource client ID
|
||||||
* @param string $client_secret Memsource client secret
|
* @param string $client_secret Memsource client secret
|
||||||
* @param string $callback_uri URL that Memsource will redirect to
|
* @param string $callback_uri URL that Memsource will redirect to
|
||||||
*
|
*
|
||||||
* @return string the authorization code
|
* @return string the authorization code
|
||||||
*/
|
*/
|
||||||
public function getAuthorizationCodeUrl(string $client_id, string $callback_uri)
|
public function getAuthorizationCodeUrl(string $client_id, string $callback_uri)
|
||||||
@ -37,10 +38,7 @@ class Oauth extends \BrunoFontes\Memsource
|
|||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => $content
|
CURLOPT_POSTFIELDS => $content
|
||||||
];
|
];
|
||||||
$response = $this->curl($token_url, $params);
|
$response = json_decode($this->curl($token_url, $params), true);
|
||||||
if ($respose['error']) {
|
|
||||||
throw new Exception("Error getting access token", 1);
|
|
||||||
}
|
|
||||||
return $response['access_token'];
|
return $response['access_token'];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user