3
3
* You must loggedin for uploading.
4
4
* This plugin doesn't support transloading.
5
5
*
6
- * @lastupdate May 27, 2014
6
+ * @lastupdate Jan 20, 2015
7
7
*/
8
8
9
9
class ChipVN_ImageUploader_Plugins_Picasa extends ChipVN_ImageUploader_Plugins_Abstract
10
10
{
11
- const API_ENDPOINT = 'https://picasaweb.google.com/data/feed/api ' ;
12
- const PATH_USER = 'user ' ;
13
- const PATH_ALBUMID = 'albumid ' ;
11
+ const CLIENT_LOGIN_ENDPOINT = 'https://www.google.com/accounts/ClientLogin ' ;
12
+ const API_ENDPOINT = 'https://picasaweb.google.com/data/feed/api ' ;
13
+ const PATH_USER = 'user ' ;
14
+ const PATH_ALBUMID = 'albumid ' ;
15
+
16
+ const SESSION_LOGIN = 'session_login ' ;
14
17
15
18
/*
16
19
* AlbumId to archive image.
@@ -34,7 +37,7 @@ protected function doLogin()
34
37
// normalize username
35
38
$ this ->username = preg_replace ('#@gmail\.com#i ' , '' , $ this ->username );
36
39
37
- if (!$ this ->getCache ()->get ( ' session_login ' )) {
40
+ if (!$ this ->getCache ()->has ( self :: SESSION_LOGIN )) {
38
41
$ this ->resetHttpClient ()
39
42
->setParameters (array (
40
43
'accountType ' => 'HOSTED_OR_GOOGLE ' ,
@@ -43,21 +46,21 @@ protected function doLogin()
43
46
'source ' => self ::POWERED_BY ,
44
47
'service ' => 'lh2 ' ,
45
48
))
46
- ->execute (' https://www.google.com/accounts/ClientLogin ' , 'POST ' );
49
+ ->execute (self :: CLIENT_LOGIN_ENDPOINT , 'POST ' );
47
50
48
51
$ this ->checkHttpClientErrors (__METHOD__ );
49
52
50
53
if ($ cookie = $ this ->getMatch ('#Auth=([a-z0-9_\-]+)#i ' , $ this ->client )) {
51
- $ this ->getCache ()->set (' session_login ' , $ cookie , 900 );
54
+ $ this ->getCache ()->set (self :: SESSION_LOGIN , $ cookie , 900 );
52
55
} elseif (
53
56
($ error = $ this ->getMatch ('#Error=(.+)#i ' , $ this ->client ))
54
57
&& ($ info = $ this ->getMatch ('#Info=(.+)#i ' , $ this ->client ))
55
58
) {
56
- $ this ->getCache ()->deleteGroup ( $ this -> getIdentifier () );
59
+ $ this ->getCache ()->delete ( self :: SESSION_LOGIN );
57
60
58
61
$ this ->throwException ('%s: Error=%s. Info=%s ' , __METHOD__ , $ error , $ info );
59
62
} else {
60
- $ this ->getCache ()->deleteGroup ( $ this -> getIdentifier () );
63
+ $ this ->getCache ()->delete ( self :: SESSION_LOGIN );
61
64
62
65
$ this ->throwException ('%s: Login failed. ' , __METHOD__ );
63
66
}
@@ -177,7 +180,7 @@ private function getAlbumEndpoint($albumId)
177
180
*/
178
181
private function checkPermission ($ method )
179
182
{
180
- if (!$ this ->getCache ()->get ( ' session_login ' )) {
183
+ if (!$ this ->getCache ()->has ( self :: SESSION_LOGIN )) {
181
184
$ this ->throwException ('You must be logged in before call the method "%s" ' , $ method );
182
185
}
183
186
}
@@ -190,7 +193,7 @@ private function checkPermission($method)
190
193
private function getGeneralHeaders ()
191
194
{
192
195
return array (
193
- "Authorization: GoogleLogin auth= " .$ this ->getCache ()->get (' session_login ' ),
196
+ "Authorization: GoogleLogin auth= " .$ this ->getCache ()->get (self :: SESSION_LOGIN ),
194
197
"MIME-Version: 1.0 " ,
195
198
);
196
199
}
0 commit comments