-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMogreet.php
More file actions
61 lines (50 loc) · 1.87 KB
/
Mogreet.php
File metadata and controls
61 lines (50 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$dir = dirname(__FILE__);
require_once($dir . '/lib/Request.php');
require_once($dir . '/lib/Response.php');
require_once($dir . '/lib/Exception.php');
require_once($dir . '/lib/Utils.php');
require_once($dir . '/lib/Keyword.php');
require_once($dir . '/lib/Media.php');
require_once($dir . '/lib/System.php');
require_once($dir . '/lib/Transaction.php');
require_once($dir . '/lib/User.php');
require_once($dir . '/lib/List.php');
if (!function_exists('curl_init')) {
throw new Exception('mogreet-php needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
throw new Exception('mogreet-php needs the JSON PHP extension.');
}
class Mogreet
{
const USER_AGENT = 'mogret-php/1.0';
const BASE_API = 'https://api.mogreet.com';
private $clientId;
private $token;
private $defaultFormat;
public function __construct($clientId, $token)
{
$this->clientId = $clientId;
$this->token = $token;
$this->defaultFormat = 'json';
$this->keyword = new Mogreet_Keyword($this);
$this->media = new Mogreet_Media($this);
$this->system = new Mogreet_System($this);
$this->transaction = new Mogreet_Transaction($this);
$this->user = new Mogreet_User($this);
$this->list = new Mogreet_List($this);
}
public function processRequest($base, $api, array $params = array(), $multipart = false)
{
// TODO implement flag to do post/get
$params = array_merge($params, $this->_getDefaultApiParams());
$data = Mogreet_Request::postRequest($base, $api, $params, $multipart);
return new Mogreet_Response($params['format'], $data);
}
protected function _getDefaultApiParams()
{
return [ "client_id" => $this->clientId, "token" => $this->token, "format" => $this->defaultFormat ];
}
}
?>