-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_api_request.php
More file actions
49 lines (41 loc) · 1.34 KB
/
_api_request.php
File metadata and controls
49 lines (41 loc) · 1.34 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
<?php
/**
* Simple class api request
* Your can use https://github.com/vipparcel/vipparcel-client-php
*/
class API_Request {
private static function curl_client($resource, $query = array())
{
$c = require '_config.php';
$ch = curl_init($c['api_url'].$resource.'?authToken='.self::auth_token().'&'.http_build_query($query));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
return json_decode(curl_exec($ch), TRUE);
}
public static function is_auth()
{
return ! empty($_SESSION['vipparcel_access']);
}
public static function user_id()
{
return $_SESSION['vipparcel_access']['user_id'];
}
public static function auth_token()
{
return $_SESSION['vipparcel_access']['access_token'];
}
public static function personal_info()
{
return self::curl_client('/account/personalInfo/details');
}
public static function label()
{
return self::curl_client('/shipping/label/getList', array('limit' => 1, 'orderBy' => array('created' => 'desc')));
}
public static function balance()
{
return self::curl_client('/account/balance/getCurrent');
}
}