-
Notifications
You must be signed in to change notification settings - Fork 3
/
MyOpenSpaceAPI.php
executable file
·171 lines (133 loc) · 5.27 KB
/
MyOpenSpaceAPI.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
require_once("Common.php");
require_once("Config.php");
require_once("BaseAPI.php");
class MyOpenSpaceAPI extends BaseAPI {
private $opensocial_token = "";
private $opensocial_view = "";
private $opensocial_detail = "";
private $context = "";
public function set_opensocial_view($view) {
$this->opensocial_view = $view;
}
public function set_opensocial_detail($detail) {
$this->opensocial_detail = $detail;
}
public function set_openocial_token($token) {
$this->opensocial_token = $token;
}
public function set_context($context) {
$this->context = $context;
}
//ctor
public function __construct($opensocial_token, $opensocial_view, $opensocial_detail) {
$this->opensocial_token = $opensocial_token;
$this->api_version = ApiVersionType::$VERSION1;
$this->resource_base = CommonConstants::$URL_OPENSOCIAL_ROOT_API;
$this->response_type = ResponseType::$XML;
$this->context = ContextType::$VIEWER;
}
// GETS get_profile
public function get_profile() {
$resource = 'profile';
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_friends
public function get_friends($page = null, $page_size = null, $list = null) {
$resource = 'friends';
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_albums
public function get_albums($album_id = null) {
$resource = 'albums';
if ($album_id != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $album_id;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_albums_photos
public function get_albums_photos($album_id) {
$resource = 'albums';
$resource .= CommonConstants::$URL_SEPERATOR . $album_id;
$resource .= CommonConstants::$URL_SEPERATOR . 'photos';
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_photos
public function get_photos($photo_id = null) {
$resource = 'photos';
if ($album_id != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $album_id;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_videos
public function get_videos($video_id = null) {
$resource = 'videos';
if ($video_id != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $video_id;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_global_appdata
public function get_global_appdata($key = null) {
$resource = 'appdata/global';
if ($key != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $key;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_appdata
public function get_appdata($key = null) {
$resource = 'appdata';
if ($key != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $key;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
// GETS get_friends_appdata
public function get_friends_appdata($key = null) {
$resource = 'friends/appdata';
if ($key != null) {
$resource .= CommonConstants::$URL_SEPERATOR . $key;
}
$result = $this->do_get($this->context, $resource, null);
return $result;
}
//DO
public function do_get($context, $resource, $headers) {
$resource_request = $this->resource_base . CommonConstants::$URL_SEPERATOR;
$resource_request .= $this->api_version . CommonConstants::$URL_SEPERATOR;
$resource_request .= $context . CommonConstants::$URL_SEPERATOR;
$resource_request .= $resource . "." . $this->get_response_type();
$resource_request .= "?";
$resource_request .= OpenSocialQueryStringList::$QS_OPEN_SOCIAL_TOKEN . "=" . $this->opensocial_token;
$resource_request .= "&";
$resource_request .= OpenSocialQueryStringList::$QS_OPEN_SOCIAL_VIEW . "=" + $this->opensocial_view;
$resource_request .= "&";
$resource_request .= OpenSocialQueryStringList::$QS_DETAIL_TYPE . "=" + $this->opensocial_detail;
return parent::_do_get($resource_request, $headers);
}
//DO
public function do_post($resource, $post_data, $headers) {
//TODO:
return parent::_do_post($resource_request, $post_data, $headers);
}
//DO
public function do_put($resource, $put_data, $headers) {
//TODO:
return parent::_do_put($resource_request, $put_data, $headers);
}
//DO
public function validate_oauth($oauth_signature) {
//TODO:
}
}
?>