Version Description
- Gmail SMTP is compatible with WordPress 5.3.
Download this release
Release Info
Developer | naa986 |
Plugin | Gmail SMTP |
Version | 1.1.9 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.1.9
- PHPMailer/PHPMailerAutoload.php +3 -1
- PHPMailer/class.phpmailer.php +15 -10
- PHPMailer/class.pop3.php +1 -1
- PHPMailer/class.smtp.php +83 -56
- PHPMailer/language/phpmailer.lang-ba.php +26 -0
- PHPMailer/language/phpmailer.lang-cs.php +1 -1
- PHPMailer/language/phpmailer.lang-nb.php +16 -16
- PHPMailer/language/phpmailer.lang-pt_br.php +2 -1
- PHPMailer/language/{phpmailer.lang-sr.php → phpmailer.lang-rs.php} +1 -1
- PHPMailer/language/phpmailer.lang-tr.php +2 -1
- PHPMailer/language/phpmailer.lang-zh_cn.php +4 -3
- class.phpmaileroauthgoogle.php +13 -5
- google-api-php-client/.gitignore +0 -7
- google-api-php-client/.travis.yml +0 -43
- google-api-php-client/CONTRIBUTING.md +0 -22
- google-api-php-client/README.md +0 -105
- google-api-php-client/autoload.php +0 -26
- google-api-php-client/composer.json +0 -25
- google-api-php-client/examples/appengineauth.php +0 -46
- google-api-php-client/examples/batch.php +0 -82
- google-api-php-client/examples/fileupload.php +0 -154
- google-api-php-client/examples/idtoken.php +0 -107
- google-api-php-client/examples/index.php +0 -19
- google-api-php-client/examples/multi-api.php +0 -114
- google-api-php-client/examples/service-account.php +0 -89
- google-api-php-client/examples/simple-query.php +0 -87
- google-api-php-client/examples/simplefileupload.php +0 -123
- google-api-php-client/examples/styles/style.css +0 -113
- google-api-php-client/examples/templates/base.php +0 -90
- google-api-php-client/examples/user-example.php +0 -132
- google-api-php-client/phpunit.xml.dist +0 -34
- google-api-php-client/src/Google/AccessToken/Revoke.php +78 -0
- google-api-php-client/src/Google/AccessToken/Verify.php +269 -0
- google-api-php-client/src/Google/Auth/Abstract.php +0 -38
- google-api-php-client/src/Google/Auth/AppIdentity.php +0 -120
- google-api-php-client/src/Google/Auth/AssertionCredentials.php +0 -136
- google-api-php-client/src/Google/Auth/ComputeEngine.php +0 -146
- google-api-php-client/src/Google/Auth/LoginTicket.php +0 -71
- google-api-php-client/src/Google/Auth/OAuth2.php +0 -638
- google-api-php-client/src/Google/Auth/Simple.php +0 -63
- google-api-php-client/src/Google/AuthHandler/AuthHandlerFactory.php +42 -0
- google-api-php-client/src/Google/AuthHandler/Guzzle5AuthHandler.php +99 -0
- google-api-php-client/src/Google/AuthHandler/Guzzle6AuthHandler.php +106 -0
- google-api-php-client/src/Google/Cache/Abstract.php +0 -53
- google-api-php-client/src/Google/Cache/Apc.php +0 -113
- google-api-php-client/src/Google/Cache/Exception.php +0 -24
- google-api-php-client/src/Google/Cache/File.php +0 -206
- google-api-php-client/src/Google/Cache/Memcache.php +0 -184
- google-api-php-client/src/Google/Cache/Null.php +0 -57
- google-api-php-client/src/Google/Client.php +717 -314
- google-api-php-client/src/Google/Collection.php +19 -19
- google-api-php-client/src/Google/Config.php +0 -452
- google-api-php-client/src/Google/Http/Batch.php +153 -49
- google-api-php-client/src/Google/Http/CacheParser.php +0 -185
- google-api-php-client/src/Google/Http/MediaFileUpload.php +120 -76
- google-api-php-client/src/Google/Http/REST.php +110 -106
- google-api-php-client/src/Google/Http/Request.php +0 -504
- google-api-php-client/src/Google/IO/Abstract.php +0 -339
- google-api-php-client/src/Google/IO/Curl.php +0 -179
- google-api-php-client/src/Google/IO/Exception.php +0 -69
- google-api-php-client/src/Google/IO/Stream.php +0 -243
- google-api-php-client/src/Google/IO/cacerts.pem +0 -2183
- google-api-php-client/src/Google/Logger/Abstract.php +0 -408
- google-api-php-client/src/Google/Logger/File.php +0 -158
- google-api-php-client/src/Google/Logger/Psr.php +0 -93
- google-api-php-client/src/Google/Model.php +35 -6
- google-api-php-client/src/Google/Service/AdExchangeBuyer.php +0 -2150
- google-api-php-client/src/Google/Service/AdExchangeSeller.php +0 -1713
- google-api-php-client/src/Google/Service/AdSense.php +0 -3586
- google-api-php-client/src/Google/Service/AdSenseHost.php +0 -2166
- google-api-php-client/src/Google/Service/Admin.php +0 -194
- google-api-php-client/src/Google/Service/Analytics.php +0 -9899
- google-api-php-client/src/Google/Service/AndroidEnterprise.php +0 -871
PHPMailer/PHPMailerAutoload.php
CHANGED
@@ -42,8 +42,10 @@ if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
|
42 |
* Fall back to traditional autoload for old PHP versions
|
43 |
* @param string $classname The name of the class to load
|
44 |
*/
|
|
|
45 |
function __autoload($classname)
|
46 |
{
|
47 |
PHPMailerAutoload($classname);
|
48 |
-
}
|
|
|
49 |
}
|
42 |
* Fall back to traditional autoload for old PHP versions
|
43 |
* @param string $classname The name of the class to load
|
44 |
*/
|
45 |
+
/* commented out this code since PHP 7.2 shows a notice even though this part is not getting executed
|
46 |
function __autoload($classname)
|
47 |
{
|
48 |
PHPMailerAutoload($classname);
|
49 |
+
}
|
50 |
+
*/
|
51 |
}
|
PHPMailer/class.phpmailer.php
CHANGED
@@ -31,7 +31,7 @@ class PHPMailer
|
|
31 |
* The PHPMailer Version number.
|
32 |
* @var string
|
33 |
*/
|
34 |
-
public $Version = '5.2.
|
35 |
|
36 |
/**
|
37 |
* Email priority.
|
@@ -440,9 +440,9 @@ class PHPMailer
|
|
440 |
*
|
441 |
* Parameters:
|
442 |
* boolean $result result of the send action
|
443 |
-
*
|
444 |
-
*
|
445 |
-
*
|
446 |
* string $subject the subject
|
447 |
* string $body the email body
|
448 |
* string $from email address of sender
|
@@ -659,6 +659,8 @@ class PHPMailer
|
|
659 |
if ($exceptions !== null) {
|
660 |
$this->exceptions = (boolean)$exceptions;
|
661 |
}
|
|
|
|
|
662 |
}
|
663 |
|
664 |
/**
|
@@ -1622,8 +1624,13 @@ class PHPMailer
|
|
1622 |
|
1623 |
foreach ($hosts as $hostentry) {
|
1624 |
$hostinfo = array();
|
1625 |
-
if (!preg_match(
|
|
|
|
|
|
|
|
|
1626 |
// Not a valid host entry
|
|
|
1627 |
continue;
|
1628 |
}
|
1629 |
// $hostinfo[2]: optional ssl or tls prefix
|
@@ -1742,6 +1749,7 @@ class PHPMailer
|
|
1742 |
'dk' => 'da',
|
1743 |
'no' => 'nb',
|
1744 |
'se' => 'sv',
|
|
|
1745 |
);
|
1746 |
|
1747 |
if (isset($renamed_langcodes[$langcode])) {
|
@@ -2024,10 +2032,7 @@ class PHPMailer
|
|
2024 |
{
|
2025 |
$result = '';
|
2026 |
|
2027 |
-
|
2028 |
-
$this->MessageDate = self::rfcDate();
|
2029 |
-
}
|
2030 |
-
$result .= $this->headerLine('Date', $this->MessageDate);
|
2031 |
|
2032 |
// To be created automatically by mail()
|
2033 |
if ($this->SingleTo) {
|
@@ -4033,7 +4038,7 @@ class phpmailerException extends Exception
|
|
4033 |
*/
|
4034 |
public function errorMessage()
|
4035 |
{
|
4036 |
-
$errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
|
4037 |
return $errorMsg;
|
4038 |
}
|
4039 |
}
|
31 |
* The PHPMailer Version number.
|
32 |
* @var string
|
33 |
*/
|
34 |
+
public $Version = '5.2.26';
|
35 |
|
36 |
/**
|
37 |
* Email priority.
|
440 |
*
|
441 |
* Parameters:
|
442 |
* boolean $result result of the send action
|
443 |
+
* array $to email addresses of the recipients
|
444 |
+
* array $cc cc email addresses
|
445 |
+
* array $bcc bcc email addresses
|
446 |
* string $subject the subject
|
447 |
* string $body the email body
|
448 |
* string $from email address of sender
|
659 |
if ($exceptions !== null) {
|
660 |
$this->exceptions = (boolean)$exceptions;
|
661 |
}
|
662 |
+
//Pick an appropriate debug output format automatically
|
663 |
+
$this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
|
664 |
}
|
665 |
|
666 |
/**
|
1624 |
|
1625 |
foreach ($hosts as $hostentry) {
|
1626 |
$hostinfo = array();
|
1627 |
+
if (!preg_match(
|
1628 |
+
'/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/',
|
1629 |
+
trim($hostentry),
|
1630 |
+
$hostinfo
|
1631 |
+
)) {
|
1632 |
// Not a valid host entry
|
1633 |
+
$this->edebug('Ignoring invalid host: ' . $hostentry);
|
1634 |
continue;
|
1635 |
}
|
1636 |
// $hostinfo[2]: optional ssl or tls prefix
|
1749 |
'dk' => 'da',
|
1750 |
'no' => 'nb',
|
1751 |
'se' => 'sv',
|
1752 |
+
'sr' => 'rs'
|
1753 |
);
|
1754 |
|
1755 |
if (isset($renamed_langcodes[$langcode])) {
|
2032 |
{
|
2033 |
$result = '';
|
2034 |
|
2035 |
+
$result .= $this->headerLine('Date', $this->MessageDate == '' ? self::rfcDate() : $this->MessageDate);
|
|
|
|
|
|
|
2036 |
|
2037 |
// To be created automatically by mail()
|
2038 |
if ($this->SingleTo) {
|
4038 |
*/
|
4039 |
public function errorMessage()
|
4040 |
{
|
4041 |
+
$errorMsg = '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
|
4042 |
return $errorMsg;
|
4043 |
}
|
4044 |
}
|
PHPMailer/class.pop3.php
CHANGED
@@ -34,7 +34,7 @@ class POP3
|
|
34 |
* @var string
|
35 |
* @access public
|
36 |
*/
|
37 |
-
public $Version = '5.2.
|
38 |
|
39 |
/**
|
40 |
* Default POP3 port number.
|
34 |
* @var string
|
35 |
* @access public
|
36 |
*/
|
37 |
+
public $Version = '5.2.26';
|
38 |
|
39 |
/**
|
40 |
* Default POP3 port number.
|
PHPMailer/class.smtp.php
CHANGED
@@ -30,7 +30,7 @@ class SMTP
|
|
30 |
* The PHPMailer SMTP version number.
|
31 |
* @var string
|
32 |
*/
|
33 |
-
const VERSION = '5.2.
|
34 |
|
35 |
/**
|
36 |
* SMTP line break constant.
|
@@ -81,7 +81,7 @@ class SMTP
|
|
81 |
* @deprecated Use the `VERSION` constant instead
|
82 |
* @see SMTP::VERSION
|
83 |
*/
|
84 |
-
public $Version = '5.2.
|
85 |
|
86 |
/**
|
87 |
* SMTP server port number.
|
@@ -150,16 +150,21 @@ class SMTP
|
|
150 |
*/
|
151 |
public $Timelimit = 300;
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
/**
|
165 |
* The socket for the server connection.
|
@@ -227,12 +232,11 @@ class SMTP
|
|
227 |
break;
|
228 |
case 'html':
|
229 |
//Cleans up output a bit for a better looking, HTML-safe output
|
230 |
-
echo htmlentities(
|
231 |
preg_replace('/[\r\n]+/', '', $str),
|
232 |
ENT_QUOTES,
|
233 |
'UTF-8'
|
234 |
-
)
|
235 |
-
. "<br>\n";
|
236 |
break;
|
237 |
case 'echo':
|
238 |
default:
|
@@ -242,7 +246,7 @@ class SMTP
|
|
242 |
"\n",
|
243 |
"\n \t ",
|
244 |
trim($str)
|
245 |
-
)."\n";
|
246 |
}
|
247 |
}
|
248 |
|
@@ -276,7 +280,8 @@ class SMTP
|
|
276 |
}
|
277 |
// Connect to the SMTP server
|
278 |
$this->edebug(
|
279 |
-
"Connection: opening to $host:$port, timeout=$timeout, options=".
|
|
|
280 |
self::DEBUG_CONNECTION
|
281 |
);
|
282 |
$errno = 0;
|
@@ -362,14 +367,14 @@ class SMTP
|
|
362 |
}
|
363 |
|
364 |
// Begin encrypted connection
|
365 |
-
|
|
|
366 |
$this->smtp_conn,
|
367 |
true,
|
368 |
$crypto_method
|
369 |
-
)
|
370 |
-
|
371 |
-
|
372 |
-
return true;
|
373 |
}
|
374 |
|
375 |
/**
|
@@ -398,8 +403,7 @@ class SMTP
|
|
398 |
}
|
399 |
|
400 |
if (array_key_exists('EHLO', $this->server_caps)) {
|
401 |
-
|
402 |
-
|
403 |
if (!array_key_exists('AUTH', $this->server_caps)) {
|
404 |
$this->setError('Authentication is not allowed at this stage');
|
405 |
// 'at this stage' means that auth may be allowed after the stage changes
|
@@ -424,7 +428,7 @@ class SMTP
|
|
424 |
$this->setError('No supported authentication methods found');
|
425 |
return false;
|
426 |
}
|
427 |
-
self::edebug('Auth method selected: '
|
428 |
}
|
429 |
|
430 |
if (!in_array($authtype, $this->server_caps['AUTH'])) {
|
@@ -550,7 +554,7 @@ class SMTP
|
|
550 |
* Works like hash_hmac('md5', $data, $key)
|
551 |
* in case that function is not available
|
552 |
* @param string $data The data to hash
|
553 |
-
* @param string $key
|
554 |
* @access protected
|
555 |
* @return string
|
556 |
*/
|
@@ -710,6 +714,7 @@ class SMTP
|
|
710 |
$savetimelimit = $this->Timelimit;
|
711 |
$this->Timelimit = $this->Timelimit * 2;
|
712 |
$result = $this->sendCommand('DATA END', '.', 250);
|
|
|
713 |
//Restore timelimit
|
714 |
$this->Timelimit = $savetimelimit;
|
715 |
return $result;
|
@@ -893,7 +898,8 @@ class SMTP
|
|
893 |
$code_ex = (count($matches) > 2 ? $matches[2] : null);
|
894 |
// Cut off error code from each response line
|
895 |
$detail = preg_replace(
|
896 |
-
"/{$code}[ -]"
|
|
|
897 |
'',
|
898 |
$this->last_reply
|
899 |
);
|
@@ -989,7 +995,10 @@ class SMTP
|
|
989 |
public function client_send($data)
|
990 |
{
|
991 |
$this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
|
992 |
-
|
|
|
|
|
|
|
993 |
}
|
994 |
|
995 |
/**
|
@@ -1089,8 +1098,10 @@ class SMTP
|
|
1089 |
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
|
1090 |
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
|
1091 |
$data .= $str;
|
1092 |
-
// If
|
1093 |
-
|
|
|
|
|
1094 |
break;
|
1095 |
}
|
1096 |
// Timed-out? Log and break
|
@@ -1105,7 +1116,7 @@ class SMTP
|
|
1105 |
// Now check if reads took too long
|
1106 |
if ($endtime and time() > $endtime) {
|
1107 |
$this->edebug(
|
1108 |
-
'SMTP -> get_lines(): timelimit reached ('.
|
1109 |
$this->Timelimit . ' sec)',
|
1110 |
self::DEBUG_LOWLEVEL
|
1111 |
);
|
@@ -1208,42 +1219,58 @@ class SMTP
|
|
1208 |
* Reports an error number and string.
|
1209 |
* @param integer $errno The error number returned by PHP.
|
1210 |
* @param string $errmsg The error message returned by PHP.
|
|
|
|
|
1211 |
*/
|
1212 |
-
protected function errorHandler($errno, $errmsg)
|
1213 |
{
|
1214 |
-
$notice = 'Connection
|
1215 |
$this->setError(
|
1216 |
$notice,
|
1217 |
$errno,
|
1218 |
$errmsg
|
1219 |
);
|
1220 |
$this->edebug(
|
1221 |
-
$notice . ' Error
|
1222 |
self::DEBUG_CONNECTION
|
1223 |
);
|
1224 |
}
|
1225 |
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1248 |
}
|
1249 |
}
|
30 |
* The PHPMailer SMTP version number.
|
31 |
* @var string
|
32 |
*/
|
33 |
+
const VERSION = '5.2.26';
|
34 |
|
35 |
/**
|
36 |
* SMTP line break constant.
|
81 |
* @deprecated Use the `VERSION` constant instead
|
82 |
* @see SMTP::VERSION
|
83 |
*/
|
84 |
+
public $Version = '5.2.26';
|
85 |
|
86 |
/**
|
87 |
* SMTP server port number.
|
150 |
*/
|
151 |
public $Timelimit = 300;
|
152 |
|
153 |
+
/**
|
154 |
+
* @var array Patterns to extract an SMTP transaction id from reply to a DATA command.
|
155 |
+
* The first capture group in each regex will be used as the ID.
|
156 |
+
*/
|
157 |
+
protected $smtp_transaction_id_patterns = array(
|
158 |
+
'exim' => '/[0-9]{3} OK id=(.*)/',
|
159 |
+
'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/',
|
160 |
+
'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/'
|
161 |
+
);
|
162 |
+
|
163 |
+
/**
|
164 |
+
* @var string The last transaction ID issued in response to a DATA command,
|
165 |
+
* if one was detected
|
166 |
+
*/
|
167 |
+
protected $last_smtp_transaction_id;
|
168 |
|
169 |
/**
|
170 |
* The socket for the server connection.
|
232 |
break;
|
233 |
case 'html':
|
234 |
//Cleans up output a bit for a better looking, HTML-safe output
|
235 |
+
echo gmdate('Y-m-d H:i:s') . ' ' . htmlentities(
|
236 |
preg_replace('/[\r\n]+/', '', $str),
|
237 |
ENT_QUOTES,
|
238 |
'UTF-8'
|
239 |
+
) . "<br>\n";
|
|
|
240 |
break;
|
241 |
case 'echo':
|
242 |
default:
|
246 |
"\n",
|
247 |
"\n \t ",
|
248 |
trim($str)
|
249 |
+
) . "\n";
|
250 |
}
|
251 |
}
|
252 |
|
280 |
}
|
281 |
// Connect to the SMTP server
|
282 |
$this->edebug(
|
283 |
+
"Connection: opening to $host:$port, timeout=$timeout, options=" .
|
284 |
+
var_export($options, true),
|
285 |
self::DEBUG_CONNECTION
|
286 |
);
|
287 |
$errno = 0;
|
367 |
}
|
368 |
|
369 |
// Begin encrypted connection
|
370 |
+
set_error_handler(array($this, 'errorHandler'));
|
371 |
+
$crypto_ok = stream_socket_enable_crypto(
|
372 |
$this->smtp_conn,
|
373 |
true,
|
374 |
$crypto_method
|
375 |
+
);
|
376 |
+
restore_error_handler();
|
377 |
+
return $crypto_ok;
|
|
|
378 |
}
|
379 |
|
380 |
/**
|
403 |
}
|
404 |
|
405 |
if (array_key_exists('EHLO', $this->server_caps)) {
|
406 |
+
// SMTP extensions are available; try to find a proper authentication method
|
|
|
407 |
if (!array_key_exists('AUTH', $this->server_caps)) {
|
408 |
$this->setError('Authentication is not allowed at this stage');
|
409 |
// 'at this stage' means that auth may be allowed after the stage changes
|
428 |
$this->setError('No supported authentication methods found');
|
429 |
return false;
|
430 |
}
|
431 |
+
self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
|
432 |
}
|
433 |
|
434 |
if (!in_array($authtype, $this->server_caps['AUTH'])) {
|
554 |
* Works like hash_hmac('md5', $data, $key)
|
555 |
* in case that function is not available
|
556 |
* @param string $data The data to hash
|
557 |
+
* @param string $key The key to hash with
|
558 |
* @access protected
|
559 |
* @return string
|
560 |
*/
|
714 |
$savetimelimit = $this->Timelimit;
|
715 |
$this->Timelimit = $this->Timelimit * 2;
|
716 |
$result = $this->sendCommand('DATA END', '.', 250);
|
717 |
+
$this->recordLastTransactionID();
|
718 |
//Restore timelimit
|
719 |
$this->Timelimit = $savetimelimit;
|
720 |
return $result;
|
898 |
$code_ex = (count($matches) > 2 ? $matches[2] : null);
|
899 |
// Cut off error code from each response line
|
900 |
$detail = preg_replace(
|
901 |
+
"/{$code}[ -]" .
|
902 |
+
($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . "/m",
|
903 |
'',
|
904 |
$this->last_reply
|
905 |
);
|
995 |
public function client_send($data)
|
996 |
{
|
997 |
$this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
|
998 |
+
set_error_handler(array($this, 'errorHandler'));
|
999 |
+
$result = fwrite($this->smtp_conn, $data);
|
1000 |
+
restore_error_handler();
|
1001 |
+
return $result;
|
1002 |
}
|
1003 |
|
1004 |
/**
|
1098 |
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
|
1099 |
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
|
1100 |
$data .= $str;
|
1101 |
+
// If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
|
1102 |
+
// or 4th character is a space, we are done reading, break the loop,
|
1103 |
+
// string array access is a micro-optimisation over strlen
|
1104 |
+
if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) {
|
1105 |
break;
|
1106 |
}
|
1107 |
// Timed-out? Log and break
|
1116 |
// Now check if reads took too long
|
1117 |
if ($endtime and time() > $endtime) {
|
1118 |
$this->edebug(
|
1119 |
+
'SMTP -> get_lines(): timelimit reached (' .
|
1120 |
$this->Timelimit . ' sec)',
|
1121 |
self::DEBUG_LOWLEVEL
|
1122 |
);
|
1219 |
* Reports an error number and string.
|
1220 |
* @param integer $errno The error number returned by PHP.
|
1221 |
* @param string $errmsg The error message returned by PHP.
|
1222 |
+
* @param string $errfile The file the error occurred in
|
1223 |
+
* @param integer $errline The line number the error occurred on
|
1224 |
*/
|
1225 |
+
protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0)
|
1226 |
{
|
1227 |
+
$notice = 'Connection failed.';
|
1228 |
$this->setError(
|
1229 |
$notice,
|
1230 |
$errno,
|
1231 |
$errmsg
|
1232 |
);
|
1233 |
$this->edebug(
|
1234 |
+
$notice . ' Error #' . $errno . ': ' . $errmsg . " [$errfile line $errline]",
|
1235 |
self::DEBUG_CONNECTION
|
1236 |
);
|
1237 |
}
|
1238 |
|
1239 |
+
/**
|
1240 |
+
* Extract and return the ID of the last SMTP transaction based on
|
1241 |
+
* a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
|
1242 |
+
* Relies on the host providing the ID in response to a DATA command.
|
1243 |
+
* If no reply has been received yet, it will return null.
|
1244 |
+
* If no pattern was matched, it will return false.
|
1245 |
+
* @return bool|null|string
|
1246 |
+
*/
|
1247 |
+
protected function recordLastTransactionID()
|
1248 |
+
{
|
1249 |
+
$reply = $this->getLastReply();
|
1250 |
+
|
1251 |
+
if (empty($reply)) {
|
1252 |
+
$this->last_smtp_transaction_id = null;
|
1253 |
+
} else {
|
1254 |
+
$this->last_smtp_transaction_id = false;
|
1255 |
+
foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
|
1256 |
+
if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
|
1257 |
+
$this->last_smtp_transaction_id = $matches[1];
|
1258 |
+
}
|
1259 |
+
}
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
return $this->last_smtp_transaction_id;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
/**
|
1266 |
+
* Get the queue/transaction ID of the last SMTP transaction
|
1267 |
+
* If no reply has been received yet, it will return null.
|
1268 |
+
* If no pattern was matched, it will return false.
|
1269 |
+
* @return bool|null|string
|
1270 |
+
* @see recordLastTransactionID()
|
1271 |
+
*/
|
1272 |
+
public function getLastTransactionID()
|
1273 |
+
{
|
1274 |
+
return $this->last_smtp_transaction_id;
|
1275 |
}
|
1276 |
}
|
PHPMailer/language/phpmailer.lang-ba.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Bosnian PHPMailer language file: refer to English translation for definitive list
|
4 |
+
* @package PHPMailer
|
5 |
+
* @author Ermin Islamagić <ermin@islamagic.com>
|
6 |
+
*/
|
7 |
+
|
8 |
+
$PHPMAILER_LANG['authenticate'] = 'SMTP Greška: Neuspjela prijava.';
|
9 |
+
$PHPMAILER_LANG['connect_host'] = 'SMTP Greška: Ne moguće se spojiti sa SMTP serverom.';
|
10 |
+
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Greška: Podatci nisu prihvaćeni.';
|
11 |
+
$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.';
|
12 |
+
$PHPMAILER_LANG['encoding'] = 'Nepoznata kriptografija: ';
|
13 |
+
$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: ';
|
14 |
+
$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: ';
|
15 |
+
$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: ';
|
16 |
+
$PHPMAILER_LANG['from_failed'] = 'SMTP Greška: Slanje sa navedenih e-mail adresa nije uspjelo: ';
|
17 |
+
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Greška: Slanje na navedene e-mail adrese nije uspjelo: ';
|
18 |
+
$PHPMAILER_LANG['instantiate'] = 'Ne mogu pokrenuti mail funkcionalnost.';
|
19 |
+
$PHPMAILER_LANG['invalid_address'] = 'E-mail nije poslan. Neispravna e-mail adresa: ';
|
20 |
+
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nije podržan.';
|
21 |
+
$PHPMAILER_LANG['provide_address'] = 'Definišite barem jednu adresu primaoca.';
|
22 |
+
$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: ';
|
23 |
+
$PHPMAILER_LANG['smtp_connect_failed'] = 'Spajanje na SMTP server nije uspjelo.';
|
24 |
+
$PHPMAILER_LANG['smtp_error'] = 'SMTP greška: ';
|
25 |
+
$PHPMAILER_LANG['variable_set'] = 'Nije moguće postaviti varijablu ili je vratiti nazad: ';
|
26 |
+
$PHPMAILER_LANG['extension_missing'] = 'Nedostaje ekstenzija: ';
|
PHPMailer/language/phpmailer.lang-cs.php
CHANGED
@@ -22,4 +22,4 @@ $PHPMAILER_LANG['signing'] = 'Chyba přihlašování: ';
|
|
22 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() selhal.';
|
23 |
$PHPMAILER_LANG['smtp_error'] = 'Chyba SMTP serveru: ';
|
24 |
$PHPMAILER_LANG['variable_set'] = 'Nelze nastavit nebo změnit proměnnou: ';
|
25 |
-
|
22 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() selhal.';
|
23 |
$PHPMAILER_LANG['smtp_error'] = 'Chyba SMTP serveru: ';
|
24 |
$PHPMAILER_LANG['variable_set'] = 'Nelze nastavit nebo změnit proměnnou: ';
|
25 |
+
$PHPMAILER_LANG['extension_missing'] = 'Chybí rozšíření: ';
|
PHPMailer/language/phpmailer.lang-nb.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Norwegian PHPMailer language file: refer to English translation for definitive list
|
4 |
* @package PHPMailer
|
5 |
*/
|
6 |
|
7 |
$PHPMAILER_LANG['authenticate'] = 'SMTP Feil: Kunne ikke autentisere.';
|
8 |
$PHPMAILER_LANG['connect_host'] = 'SMTP Feil: Kunne ikke koble til SMTP tjener.';
|
9 |
-
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Feil:
|
10 |
-
$PHPMAILER_LANG['empty_message'] = '
|
11 |
-
$PHPMAILER_LANG['encoding'] = 'Ukjent
|
12 |
$PHPMAILER_LANG['execute'] = 'Kunne ikke utføre: ';
|
13 |
$PHPMAILER_LANG['file_access'] = 'Får ikke tilgang til filen: ';
|
14 |
-
$PHPMAILER_LANG['file_open'] = 'Fil
|
15 |
-
$PHPMAILER_LANG['from_failed'] = 'Følgende
|
16 |
-
$PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere
|
17 |
-
$PHPMAILER_LANG['invalid_address'] = '
|
18 |
-
$PHPMAILER_LANG['
|
19 |
-
$PHPMAILER_LANG['
|
20 |
-
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feil: Følgende
|
21 |
-
$PHPMAILER_LANG['signing'] = '
|
22 |
-
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP
|
23 |
-
$PHPMAILER_LANG['smtp_error'] = 'SMTP
|
24 |
-
$PHPMAILER_LANG['variable_set'] = 'Kan ikke
|
25 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Norwegian Bokmål PHPMailer language file: refer to English translation for definitive list
|
4 |
* @package PHPMailer
|
5 |
*/
|
6 |
|
7 |
$PHPMAILER_LANG['authenticate'] = 'SMTP Feil: Kunne ikke autentisere.';
|
8 |
$PHPMAILER_LANG['connect_host'] = 'SMTP Feil: Kunne ikke koble til SMTP tjener.';
|
9 |
+
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Feil: Datainnhold ikke akseptert.';
|
10 |
+
$PHPMAILER_LANG['empty_message'] = 'Melding kropp tomt';
|
11 |
+
$PHPMAILER_LANG['encoding'] = 'Ukjent koding: ';
|
12 |
$PHPMAILER_LANG['execute'] = 'Kunne ikke utføre: ';
|
13 |
$PHPMAILER_LANG['file_access'] = 'Får ikke tilgang til filen: ';
|
14 |
+
$PHPMAILER_LANG['file_open'] = 'Fil Feil: Kunne ikke åpne filen: ';
|
15 |
+
$PHPMAILER_LANG['from_failed'] = 'Følgende Frå adresse feilet: ';
|
16 |
+
$PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere post funksjon.';
|
17 |
+
$PHPMAILER_LANG['invalid_address'] = 'Ugyldig adresse: ';
|
18 |
+
$PHPMAILER_LANG['mailer_not_supported'] = ' sender er ikke støttet.';
|
19 |
+
$PHPMAILER_LANG['provide_address'] = 'Du må opppgi minst en mottakeradresse.';
|
20 |
+
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feil: Følgende mottakeradresse feilet: ';
|
21 |
+
$PHPMAILER_LANG['signing'] = 'Signering Feil: ';
|
22 |
+
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP connect() feilet.';
|
23 |
+
$PHPMAILER_LANG['smtp_error'] = 'SMTP server feil: ';
|
24 |
+
$PHPMAILER_LANG['variable_set'] = 'Kan ikke skrive eller omskrive variabel: ';
|
25 |
+
$PHPMAILER_LANG['extension_missing'] = 'Utvidelse mangler: ';
|
PHPMailer/language/phpmailer.lang-pt_br.php
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
* @author Paulo Henrique Garcia <paulo@controllerweb.com.br>
|
6 |
* @author Lucas Guimarães <lucas@lucasguimaraes.com>
|
7 |
* @author Phelipe Alves <phelipealvesdesouza@gmail.com>
|
|
|
8 |
*/
|
9 |
|
10 |
$PHPMAILER_LANG['authenticate'] = 'Erro de SMTP: Não foi possível autenticar.';
|
@@ -15,7 +16,7 @@ $PHPMAILER_LANG['encoding'] = 'Codificação desconhecida: ';
|
|
15 |
$PHPMAILER_LANG['execute'] = 'Não foi possível executar: ';
|
16 |
$PHPMAILER_LANG['file_access'] = 'Não foi possível acessar o arquivo: ';
|
17 |
$PHPMAILER_LANG['file_open'] = 'Erro de Arquivo: Não foi possível abrir o arquivo: ';
|
18 |
-
$PHPMAILER_LANG['from_failed'] = 'Os seguintes
|
19 |
$PHPMAILER_LANG['instantiate'] = 'Não foi possível instanciar a função mail.';
|
20 |
$PHPMAILER_LANG['invalid_address'] = 'Endereço de e-mail inválido: ';
|
21 |
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.';
|
5 |
* @author Paulo Henrique Garcia <paulo@controllerweb.com.br>
|
6 |
* @author Lucas Guimarães <lucas@lucasguimaraes.com>
|
7 |
* @author Phelipe Alves <phelipealvesdesouza@gmail.com>
|
8 |
+
* @author Fabio Beneditto <fabiobeneditto@gmail.com>
|
9 |
*/
|
10 |
|
11 |
$PHPMAILER_LANG['authenticate'] = 'Erro de SMTP: Não foi possível autenticar.';
|
16 |
$PHPMAILER_LANG['execute'] = 'Não foi possível executar: ';
|
17 |
$PHPMAILER_LANG['file_access'] = 'Não foi possível acessar o arquivo: ';
|
18 |
$PHPMAILER_LANG['file_open'] = 'Erro de Arquivo: Não foi possível abrir o arquivo: ';
|
19 |
+
$PHPMAILER_LANG['from_failed'] = 'Os seguintes remetentes falharam: ';
|
20 |
$PHPMAILER_LANG['instantiate'] = 'Não foi possível instanciar a função mail.';
|
21 |
$PHPMAILER_LANG['invalid_address'] = 'Endereço de e-mail inválido: ';
|
22 |
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.';
|
PHPMailer/language/{phpmailer.lang-sr.php → phpmailer.lang-rs.php}
RENAMED
@@ -23,4 +23,4 @@ $PHPMAILER_LANG['signing'] = 'Грешка приликом при
|
|
23 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'Повезивање са SMTP сервером није успело.';
|
24 |
$PHPMAILER_LANG['smtp_error'] = 'Грешка SMTP сервера: ';
|
25 |
$PHPMAILER_LANG['variable_set'] = 'Није могуће задати променљиву, нити је вратити уназад: ';
|
26 |
-
|
23 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'Повезивање са SMTP сервером није успело.';
|
24 |
$PHPMAILER_LANG['smtp_error'] = 'Грешка SMTP сервера: ';
|
25 |
$PHPMAILER_LANG['variable_set'] = 'Није могуће задати променљиву, нити је вратити уназад: ';
|
26 |
+
$PHPMAILER_LANG['extension_missing'] = 'Недостаје проширење: ';
|
PHPMailer/language/phpmailer.lang-tr.php
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
* @author Can Yılmaz
|
7 |
* @author Mehmet Benlioğlu
|
8 |
* @author @yasinaydin
|
|
|
9 |
*/
|
10 |
|
11 |
$PHPMAILER_LANG['authenticate'] = 'SMTP Hatası: Oturum açılamadı.';
|
@@ -26,4 +27,4 @@ $PHPMAILER_LANG['signing'] = 'İmzalama hatası: ';
|
|
26 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP connect() fonksiyonu başarısız.';
|
27 |
$PHPMAILER_LANG['smtp_error'] = 'SMTP sunucu hatası: ';
|
28 |
$PHPMAILER_LANG['variable_set'] = 'Değişken ayarlanamadı ya da sıfırlanamadı: ';
|
29 |
-
|
6 |
* @author Can Yılmaz
|
7 |
* @author Mehmet Benlioğlu
|
8 |
* @author @yasinaydin
|
9 |
+
* @author Ogün Karakuş
|
10 |
*/
|
11 |
|
12 |
$PHPMAILER_LANG['authenticate'] = 'SMTP Hatası: Oturum açılamadı.';
|
27 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP connect() fonksiyonu başarısız.';
|
28 |
$PHPMAILER_LANG['smtp_error'] = 'SMTP sunucu hatası: ';
|
29 |
$PHPMAILER_LANG['variable_set'] = 'Değişken ayarlanamadı ya da sıfırlanamadı: ';
|
30 |
+
$PHPMAILER_LANG['extension_missing'] = 'Eklenti bulunamadı: ';
|
PHPMailer/language/phpmailer.lang-zh_cn.php
CHANGED
@@ -4,13 +4,14 @@
|
|
4 |
* @package PHPMailer
|
5 |
* @author liqwei <liqwei@liqwei.com>
|
6 |
* @author young <masxy@foxmail.com>
|
|
|
7 |
*/
|
8 |
|
9 |
$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。';
|
10 |
$PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。';
|
11 |
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。';
|
12 |
$PHPMAILER_LANG['empty_message'] = '邮件正文为空。';
|
13 |
-
$PHPMAILER_LANG['encoding'] = '
|
14 |
$PHPMAILER_LANG['execute'] = '无法执行:';
|
15 |
$PHPMAILER_LANG['file_access'] = '无法访问文件:';
|
16 |
$PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:';
|
@@ -22,6 +23,6 @@ $PHPMAILER_LANG['provide_address'] = '必须提供至少一个收件人地
|
|
22 |
$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:';
|
23 |
$PHPMAILER_LANG['signing'] = '登录失败:';
|
24 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP服务器连接失败。';
|
25 |
-
$PHPMAILER_LANG['smtp_error'] = 'SMTP
|
26 |
$PHPMAILER_LANG['variable_set'] = '无法设置或重置变量:';
|
27 |
-
|
4 |
* @package PHPMailer
|
5 |
* @author liqwei <liqwei@liqwei.com>
|
6 |
* @author young <masxy@foxmail.com>
|
7 |
+
* @author Teddysun <i@teddysun.com>
|
8 |
*/
|
9 |
|
10 |
$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。';
|
11 |
$PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。';
|
12 |
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。';
|
13 |
$PHPMAILER_LANG['empty_message'] = '邮件正文为空。';
|
14 |
+
$PHPMAILER_LANG['encoding'] = '未知编码:';
|
15 |
$PHPMAILER_LANG['execute'] = '无法执行:';
|
16 |
$PHPMAILER_LANG['file_access'] = '无法访问文件:';
|
17 |
$PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:';
|
23 |
$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:';
|
24 |
$PHPMAILER_LANG['signing'] = '登录失败:';
|
25 |
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP服务器连接失败。';
|
26 |
+
$PHPMAILER_LANG['smtp_error'] = 'SMTP服务器出错:';
|
27 |
$PHPMAILER_LANG['variable_set'] = '无法设置或重置变量:';
|
28 |
+
$PHPMAILER_LANG['extension_missing'] = '丢失模块 Extension:';
|
class.phpmaileroauthgoogle.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
|
|
2 |
define ( 'SCOPES', implode ( ' ', array (
|
3 |
\Google_Service_Gmail::GMAIL_COMPOSE
|
4 |
) ) );
|
5 |
-
|
6 |
class GmailXOAuth2 {
|
7 |
|
8 |
private $oauthUserEmail = '';
|
@@ -74,7 +75,7 @@ class GmailXOAuth2 {
|
|
74 |
|
75 |
$new_accessToken = $client->getAccessToken();
|
76 |
|
77 |
-
$options['oauth_access_token'] = $new_accessToken;
|
78 |
|
79 |
gmail_smtp_update_option($options);
|
80 |
|
@@ -101,9 +102,16 @@ class GmailXOAuth2 {
|
|
101 |
$options = gmail_smtp_get_option();
|
102 |
|
103 |
if(!empty($accessToken)) {
|
104 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
gmail_smtp_update_option($options);
|
106 |
-
return
|
107 |
|
108 |
}
|
109 |
|
@@ -143,7 +151,7 @@ class GmailXOAuth2 {
|
|
143 |
|
144 |
$accessToken = $client->getAccessToken();
|
145 |
|
146 |
-
$options['oauth_access_token'] = $accessToken;
|
147 |
gmail_smtp_update_option($options);
|
148 |
|
149 |
}
|
1 |
<?php
|
2 |
+
/*
|
3 |
define ( 'SCOPES', implode ( ' ', array (
|
4 |
\Google_Service_Gmail::GMAIL_COMPOSE
|
5 |
) ) );
|
6 |
+
*/
|
7 |
class GmailXOAuth2 {
|
8 |
|
9 |
private $oauthUserEmail = '';
|
75 |
|
76 |
$new_accessToken = $client->getAccessToken();
|
77 |
|
78 |
+
$options['oauth_access_token'] = json_encode($new_accessToken); //json_encode the token since getAccessToken() no longer encodes it
|
79 |
|
80 |
gmail_smtp_update_option($options);
|
81 |
|
102 |
$options = gmail_smtp_get_option();
|
103 |
|
104 |
if(!empty($accessToken)) {
|
105 |
+
if(isset($accessToken['error']) || isset($accessToken['error_description'])){
|
106 |
+
echo '<div id="message" class="error"><p><strong>';
|
107 |
+
echo __('Error: '.$accessToken['error'].', Error Description: '.$accessToken['error_description'], 'gmail-smtp');
|
108 |
+
echo '</strong></p></div>';
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
//json_encode the token since authenticate() function returns it as an array now. It used to call getAccessToken() before which would return in json_encoded format.
|
112 |
+
$options['oauth_access_token'] = json_encode($accessToken);
|
113 |
gmail_smtp_update_option($options);
|
114 |
+
return $accessToken;
|
115 |
|
116 |
}
|
117 |
|
151 |
|
152 |
$accessToken = $client->getAccessToken();
|
153 |
|
154 |
+
$options['oauth_access_token'] = json_encode($accessToken); //json_encode the token since getAccessToken() no longer encodes it
|
155 |
gmail_smtp_update_option($options);
|
156 |
|
157 |
}
|
google-api-php-client/.gitignore
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
.DS_Store
|
2 |
-
phpunit.xml
|
3 |
-
composer.lock
|
4 |
-
vendor
|
5 |
-
examples/testfile-small.txt
|
6 |
-
examples/testfile.txt
|
7 |
-
tests/.accessToken
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/.travis.yml
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
language: php
|
2 |
-
|
3 |
-
services:
|
4 |
-
- memcached
|
5 |
-
|
6 |
-
env:
|
7 |
-
global:
|
8 |
-
- MEMCACHE_HOST=127.0.0.1
|
9 |
-
- MEMCACHE_PORT=11211
|
10 |
-
|
11 |
-
sudo: false
|
12 |
-
|
13 |
-
cache:
|
14 |
-
directories:
|
15 |
-
- $HOME/.composer/cache
|
16 |
-
|
17 |
-
matrix:
|
18 |
-
fast_finish: true
|
19 |
-
include:
|
20 |
-
# Can't test against 5.2; openssl is not available:
|
21 |
-
# http://docs.travis-ci.com/user/languages/php/#PHP-installation
|
22 |
-
- php: 5.3
|
23 |
-
- php: 5.4
|
24 |
-
- php: 5.5
|
25 |
-
- php: 5.6
|
26 |
-
env: PHPCS=true
|
27 |
-
- php: hhvm
|
28 |
-
|
29 |
-
before_install:
|
30 |
-
- composer self-update
|
31 |
-
|
32 |
-
install:
|
33 |
-
- composer install
|
34 |
-
|
35 |
-
before_script:
|
36 |
-
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
|
37 |
-
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
|
38 |
-
- phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
|
39 |
-
- phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
|
40 |
-
|
41 |
-
script:
|
42 |
-
- vendor/bin/phpunit
|
43 |
-
- if [[ "$PHPCS" == "true" ]]; then vendor/bin/phpcs src --standard=style/ruleset.xml -np; fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/CONTRIBUTING.md
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
# How to become a contributor and submit your own code
|
2 |
-
|
3 |
-
## Contributor License Agreements
|
4 |
-
|
5 |
-
We'd love to accept your code patches! However, before we can take them, we have to jump a couple of legal hurdles.
|
6 |
-
|
7 |
-
Please fill out either the individual or corporate Contributor License Agreement (CLA).
|
8 |
-
|
9 |
-
* If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).
|
10 |
-
* If you work for a company that wants to allow you to contribute your work to this client library, then you'll need to sign a[corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
|
11 |
-
|
12 |
-
Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll add you to the official list of contributors and be able to accept your patches.
|
13 |
-
|
14 |
-
## Submitting Patches
|
15 |
-
|
16 |
-
1. Fork the PHP client library on GitHub
|
17 |
-
1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the issue tracker. Please file one change per issue, and address one issue per change. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please file a new ticket!
|
18 |
-
1. Ensure that your code adheres to standard PHP conventions, as used in the rest of the library.
|
19 |
-
1. Ensure that there are unit tests for your code.
|
20 |
-
1. Sign a Contributor License Agreement (see above).
|
21 |
-
1. Submit a pull request with your patch on Github.
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/README.md
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
[![Build Status](https://travis-ci.org/google/google-api-php-client.svg)](https://travis-ci.org/google/google-api-php-client)
|
2 |
-
|
3 |
-
# Google APIs Client Library for PHP #
|
4 |
-
|
5 |
-
## Description ##
|
6 |
-
The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server.
|
7 |
-
|
8 |
-
## Beta ##
|
9 |
-
This library is in Beta. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will make an effort to support the public and protected surface of the library and maintain backwards compatibility in the future. While we are still in Beta, we reserve the right to make incompatible changes. If we do remove some functionality (typically because better functionality exists or if the feature proved infeasible), our intention is to deprecate and provide ample time for developers to update their code.
|
10 |
-
|
11 |
-
## Requirements ##
|
12 |
-
* [PHP 5.2.1 or higher](http://www.php.net/)
|
13 |
-
* [PHP JSON extension](http://php.net/manual/en/book.json.php)
|
14 |
-
|
15 |
-
*Note*: some features (service accounts and id token verification) require PHP 5.3.0 and above due to cryptographic algorithm requirements.
|
16 |
-
|
17 |
-
## Developer Documentation ##
|
18 |
-
http://developers.google.com/api-client-library/php
|
19 |
-
|
20 |
-
## Installation ##
|
21 |
-
|
22 |
-
For the latest installation and setup instructions, see [the documentation](https://developers.google.com/api-client-library/php/start/installation).
|
23 |
-
|
24 |
-
## Basic Example ##
|
25 |
-
See the examples/ directory for examples of the key client features.
|
26 |
-
```PHP
|
27 |
-
<?php
|
28 |
-
|
29 |
-
require_once 'google-api-php-client/src/Google/autoload.php'; // or wherever autoload.php is located
|
30 |
-
|
31 |
-
$client = new Google_Client();
|
32 |
-
$client->setApplicationName("Client_Library_Examples");
|
33 |
-
$client->setDeveloperKey("YOUR_APP_KEY");
|
34 |
-
|
35 |
-
$service = new Google_Service_Books($client);
|
36 |
-
$optParams = array('filter' => 'free-ebooks');
|
37 |
-
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
|
38 |
-
|
39 |
-
foreach ($results as $item) {
|
40 |
-
echo $item['volumeInfo']['title'], "<br /> \n";
|
41 |
-
}
|
42 |
-
|
43 |
-
```
|
44 |
-
|
45 |
-
### Service Specific Examples ###
|
46 |
-
|
47 |
-
YouTube: https://github.com/youtube/api-samples/tree/master/php
|
48 |
-
|
49 |
-
## Frequently Asked Questions ##
|
50 |
-
|
51 |
-
### What do I do if something isn't working? ###
|
52 |
-
|
53 |
-
For support with the library the best place to ask is via the google-api-php-client tag on StackOverflow: http://stackoverflow.com/questions/tagged/google-api-php-client
|
54 |
-
|
55 |
-
If there is a specific bug with the library, please file a issue in the Github issues tracker, including a (minimal) example of the failing code and any specific errors retrieved. Feature requests can also be filed, as long as they are core library requests, and not-API specific: for those, refer to the documentation for the individual APIs for the best place to file requests. Please try to provide a clear statement of the problem that the feature would address.
|
56 |
-
|
57 |
-
### How do I contribute? ###
|
58 |
-
|
59 |
-
We accept contributions via Github Pull Requests, but all contributors need to be covered by the standard Google Contributor License Agreement. You can find links, and more instructions, in the documentation: https://developers.google.com/api-client-library/php/contribute
|
60 |
-
|
61 |
-
### I want an example of X! ###
|
62 |
-
|
63 |
-
If X is a feature of the library, file away! If X is an example of using a specific service, the best place to go is to the teams for those specific APIs - our preference is to link to their examples rather than add them to the library, as they can then pin to specific versions of the library. If you have any examples for other APIs, let us know and we will happily add a link to the README above!
|
64 |
-
|
65 |
-
### Why do you still support 5.2? ###
|
66 |
-
|
67 |
-
When we started working on the 1.0.0 branch we knew there were several fundamental issues to fix with the 0.6 releases of the library. At that time we looked at the usage of the library, and other related projects, and determined that there was still a large and active base of PHP 5.2 installs. You can see this in statistics such as the PHP versions chart in the WordPress stats: http://wordpress.org/about/stats/. We will keep looking at the types of usage we see, and try to take advantage of newer PHP features where possible.
|
68 |
-
|
69 |
-
### Why does Google_..._Service have weird names? ###
|
70 |
-
|
71 |
-
The _Service classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
|
72 |
-
|
73 |
-
### How do I deal with non-JSON response types? ###
|
74 |
-
|
75 |
-
Some services return XML or similar by default, rather than JSON, which is what the library supports. You can request a JSON response by adding an 'alt' argument to optional params that is normally the last argument to a method call:
|
76 |
-
|
77 |
-
```
|
78 |
-
$opt_params = array(
|
79 |
-
'alt' => "json"
|
80 |
-
);
|
81 |
-
```
|
82 |
-
|
83 |
-
### How do I set a field to null? ###
|
84 |
-
|
85 |
-
The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialised properties. To work around this, set the field you want to null to Google_Model::NULL_VALUE. This is a placeholder that will be replaced with a true null when sent over the wire.
|
86 |
-
|
87 |
-
## Code Quality ##
|
88 |
-
|
89 |
-
Run the PHPUnit tests with PHPUnit. You can configure an API key and token in BaseTest.php to run all calls, but this will require some setup on the Google Developer Console.
|
90 |
-
|
91 |
-
phpunit tests/
|
92 |
-
|
93 |
-
### Coding Style
|
94 |
-
|
95 |
-
To check for coding style violations, run
|
96 |
-
|
97 |
-
```
|
98 |
-
vendor/bin/phpcs src --standard=style/ruleset.xml -np
|
99 |
-
```
|
100 |
-
|
101 |
-
To automatically fix (fixable) coding style violations, run
|
102 |
-
|
103 |
-
```
|
104 |
-
vendor/bin/phpcbf src --standard=style/ruleset.xml
|
105 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/autoload.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2014 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
|
18 |
-
// PHP 5.2 compatibility: E_USER_DEPRECATED was added in 5.3
|
19 |
-
if (!defined('E_USER_DEPRECATED')) {
|
20 |
-
define('E_USER_DEPRECATED', E_USER_WARNING);
|
21 |
-
}
|
22 |
-
|
23 |
-
$error = "google-api-php-client's autoloader was moved to src/Google/autoload.php in 1.1.3. This ";
|
24 |
-
$error .= "redirect will be removed in 1.2. Please adjust your code to use the new location.";
|
25 |
-
trigger_error($error, E_USER_DEPRECATED);
|
26 |
-
require_once dirname(__FILE__) . '/src/Google/autoload.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/composer.json
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "google/apiclient",
|
3 |
-
"type": "library",
|
4 |
-
"description": "Client library for Google APIs",
|
5 |
-
"keywords": ["google"],
|
6 |
-
"homepage": "http://developers.google.com/api-client-library/php",
|
7 |
-
"license": "Apache-2.0",
|
8 |
-
"require": {
|
9 |
-
"php": ">=5.2.1"
|
10 |
-
},
|
11 |
-
"require-dev": {
|
12 |
-
"phpunit/phpunit": "3.7.*",
|
13 |
-
"squizlabs/php_codesniffer": "~2.3"
|
14 |
-
},
|
15 |
-
"autoload": {
|
16 |
-
"classmap": [
|
17 |
-
"src/"
|
18 |
-
]
|
19 |
-
},
|
20 |
-
"extra": {
|
21 |
-
"branch-alias": {
|
22 |
-
"dev-master": "1.1.x-dev"
|
23 |
-
}
|
24 |
-
}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/appengineauth.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
session_start();
|
18 |
-
include_once "templates/base.php";
|
19 |
-
|
20 |
-
/************************************************
|
21 |
-
Make an API request authenticated via the
|
22 |
-
AppIdentity service on AppEngine.
|
23 |
-
************************************************/
|
24 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
25 |
-
|
26 |
-
echo pageHeader("AppIdentity Account Access");
|
27 |
-
|
28 |
-
$client = new Google_Client();
|
29 |
-
$client->setApplicationName("Client_Library_Examples");
|
30 |
-
|
31 |
-
$auth = new Google_Auth_AppIdentity($client);
|
32 |
-
$token = $auth->authenticateForScope(Google_Service_Storage::DEVSTORAGE_READ_ONLY);
|
33 |
-
if (!$token) {
|
34 |
-
die("Could not authenticate to AppIdentity service");
|
35 |
-
}
|
36 |
-
$client->setAuth($auth);
|
37 |
-
|
38 |
-
$service = new Google_Service_Storage($client);
|
39 |
-
$results = $service->buckets->listBuckets(str_replace("s~", "", $_SERVER['APPLICATION_ID']));
|
40 |
-
|
41 |
-
echo "<h3>Results Of Call:</h3>";
|
42 |
-
echo "<pre>";
|
43 |
-
var_dump($results);
|
44 |
-
echo "</pre>";
|
45 |
-
|
46 |
-
echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/batch.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
include_once "templates/base.php";
|
18 |
-
echo pageHeader("Batching Queries");
|
19 |
-
|
20 |
-
/************************************************
|
21 |
-
We're going to use the simple access to the
|
22 |
-
books API again as an example, but this time we
|
23 |
-
will batch up two queries into a single call.
|
24 |
-
************************************************/
|
25 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
26 |
-
|
27 |
-
/************************************************
|
28 |
-
We create the client and set the simple API
|
29 |
-
access key. If you comment out the call to
|
30 |
-
setDeveloperKey, the request may still succeed
|
31 |
-
using the anonymous quota.
|
32 |
-
************************************************/
|
33 |
-
$client = new Google_Client();
|
34 |
-
$client->setApplicationName("Client_Library_Examples");
|
35 |
-
$apiKey = "<YOUR_API_KEY>"; // Change to your API key.
|
36 |
-
// Warn if the API key isn't changed!
|
37 |
-
if (strpos($apiKey, "<") !== false) {
|
38 |
-
echo missingApiKeyWarning();
|
39 |
-
exit;
|
40 |
-
} else {
|
41 |
-
$client->setDeveloperKey($apiKey);
|
42 |
-
|
43 |
-
$service = new Google_Service_Books($client);
|
44 |
-
|
45 |
-
/************************************************
|
46 |
-
To actually make the batch call we need to
|
47 |
-
enable batching on the client - this will apply
|
48 |
-
globally until we set it to false. This causes
|
49 |
-
call to the service methods to return the query
|
50 |
-
rather than immediately executing.
|
51 |
-
************************************************/
|
52 |
-
$client->setUseBatch(true);
|
53 |
-
|
54 |
-
/************************************************
|
55 |
-
We then create a batch, and add each query we
|
56 |
-
want to execute with keys of our choice - these
|
57 |
-
keys will be reflected in the returned array.
|
58 |
-
************************************************/
|
59 |
-
$batch = new Google_Http_Batch($client);
|
60 |
-
$optParams = array('filter' => 'free-ebooks');
|
61 |
-
$req1 = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
|
62 |
-
$batch->add($req1, "thoreau");
|
63 |
-
$req2 = $service->volumes->listVolumes('George Bernard Shaw', $optParams);
|
64 |
-
$batch->add($req2, "shaw");
|
65 |
-
|
66 |
-
/************************************************
|
67 |
-
Executing the batch will send all requests off
|
68 |
-
at once.
|
69 |
-
************************************************/
|
70 |
-
$results = $batch->execute();
|
71 |
-
|
72 |
-
echo "<h3>Results Of Call 1:</h3>";
|
73 |
-
foreach ($results['response-thoreau'] as $item) {
|
74 |
-
echo $item['volumeInfo']['title'], "<br /> \n";
|
75 |
-
}
|
76 |
-
echo "<h3>Results Of Call 2:</h3>";
|
77 |
-
foreach ($results['response-shaw'] as $item) {
|
78 |
-
echo $item['volumeInfo']['title'], "<br /> \n";
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/fileupload.php
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2011 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
include_once "templates/base.php";
|
18 |
-
session_start();
|
19 |
-
|
20 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
21 |
-
|
22 |
-
/************************************************
|
23 |
-
We'll setup an empty 20MB file to upload.
|
24 |
-
************************************************/
|
25 |
-
DEFINE("TESTFILE", 'testfile.txt');
|
26 |
-
if (!file_exists(TESTFILE)) {
|
27 |
-
$fh = fopen(TESTFILE, 'w');
|
28 |
-
fseek($fh, 1024*1024*20);
|
29 |
-
fwrite($fh, "!", 1);
|
30 |
-
fclose($fh);
|
31 |
-
}
|
32 |
-
|
33 |
-
/************************************************
|
34 |
-
ATTENTION: Fill in these values! Make sure
|
35 |
-
the redirect URI is to this page, e.g:
|
36 |
-
http://localhost:8080/fileupload.php
|
37 |
-
************************************************/
|
38 |
-
$client_id = '<YOUR_CLIENT_ID>';
|
39 |
-
$client_secret = '<YOUR_CLIENT_SECRET>';
|
40 |
-
$redirect_uri = '<YOUR_REDIRECT_URI>';
|
41 |
-
|
42 |
-
$client = new Google_Client();
|
43 |
-
$client->setClientId($client_id);
|
44 |
-
$client->setClientSecret($client_secret);
|
45 |
-
$client->setRedirectUri($redirect_uri);
|
46 |
-
$client->addScope("https://www.googleapis.com/auth/drive");
|
47 |
-
$service = new Google_Service_Drive($client);
|
48 |
-
|
49 |
-
if (isset($_REQUEST['logout'])) {
|
50 |
-
unset($_SESSION['upload_token ']);
|
51 |
-
}
|
52 |
-
|
53 |
-
if (isset($_GET['code'])) {
|
54 |
-
$client->authenticate($_GET['code']);
|
55 |
-
$_SESSION['upload_token'] = $client->getAccessToken();
|
56 |
-
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
57 |
-
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
|
58 |
-
}
|
59 |
-
|
60 |
-
if (isset($_SESSION['upload_token']) && $_SESSION['upload_token']) {
|
61 |
-
$client->setAccessToken($_SESSION['upload_token']);
|
62 |
-
if ($client->isAccessTokenExpired()) {
|
63 |
-
unset($_SESSION['upload_token']);
|
64 |
-
}
|
65 |
-
} else {
|
66 |
-
$authUrl = $client->createAuthUrl();
|
67 |
-
}
|
68 |
-
|
69 |
-
/************************************************
|
70 |
-
If we're signed in then lets try to upload our
|
71 |
-
file.
|
72 |
-
************************************************/
|
73 |
-
if ($client->getAccessToken()) {
|
74 |
-
$file = new Google_Service_Drive_DriveFile();
|
75 |
-
$file->title = "Big File";
|
76 |
-
$chunkSizeBytes = 1 * 1024 * 1024;
|
77 |
-
|
78 |
-
// Call the API with the media upload, defer so it doesn't immediately return.
|
79 |
-
$client->setDefer(true);
|
80 |
-
$request = $service->files->insert($file);
|
81 |
-
|
82 |
-
// Create a media file upload to represent our upload process.
|
83 |
-
$media = new Google_Http_MediaFileUpload(
|
84 |
-
$client,
|
85 |
-
$request,
|
86 |
-
'text/plain',
|
87 |
-
null,
|
88 |
-
true,
|
89 |
-
$chunkSizeBytes
|
90 |
-
);
|
91 |
-
$media->setFileSize(filesize(TESTFILE));
|
92 |
-
|
93 |
-
// Upload the various chunks. $status will be false until the process is
|
94 |
-
// complete.
|
95 |
-
$status = false;
|
96 |
-
$handle = fopen(TESTFILE, "rb");
|
97 |
-
while (!$status && !feof($handle)) {
|
98 |
-
// read until you get $chunkSizeBytes from TESTFILE
|
99 |
-
// fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
|
100 |
-
// An example of a read buffered file is when reading from a URL
|
101 |
-
$chunk = readVideoChunk($handle, $chunkSizeBytes);
|
102 |
-
$status = $media->nextChunk($chunk);
|
103 |
-
}
|
104 |
-
|
105 |
-
// The final value of $status will be the data from the API for the object
|
106 |
-
// that has been uploaded.
|
107 |
-
$result = false;
|
108 |
-
if ($status != false) {
|
109 |
-
$result = $status;
|
110 |
-
}
|
111 |
-
|
112 |
-
fclose($handle);
|
113 |
-
}
|
114 |
-
echo pageHeader("File Upload - Uploading a large file");
|
115 |
-
if (strpos($client_id, "googleusercontent") == false) {
|
116 |
-
echo missingClientSecretsWarning();
|
117 |
-
exit;
|
118 |
-
}
|
119 |
-
function readVideoChunk ($handle, $chunkSize)
|
120 |
-
{
|
121 |
-
$byteCount = 0;
|
122 |
-
$giantChunk = "";
|
123 |
-
while (!feof($handle)) {
|
124 |
-
// fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
|
125 |
-
$chunk = fread($handle, 8192);
|
126 |
-
$byteCount += strlen($chunk);
|
127 |
-
$giantChunk .= $chunk;
|
128 |
-
if ($byteCount >= $chunkSize)
|
129 |
-
{
|
130 |
-
return $giantChunk;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
return $giantChunk;
|
134 |
-
}
|
135 |
-
?>
|
136 |
-
<div class="box">
|
137 |
-
<div class="request">
|
138 |
-
<?php
|
139 |
-
if (isset($authUrl)) {
|
140 |
-
echo "<a class='login' href='" . $authUrl . "'>Connect Me!</a>";
|
141 |
-
}
|
142 |
-
?>
|
143 |
-
</div>
|
144 |
-
|
145 |
-
<div class="shortened">
|
146 |
-
<?php
|
147 |
-
if (isset($result) && $result) {
|
148 |
-
var_dump($result);
|
149 |
-
}
|
150 |
-
?>
|
151 |
-
</div>
|
152 |
-
</div>
|
153 |
-
<?php
|
154 |
-
echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/idtoken.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2011 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
include_once "templates/base.php";
|
18 |
-
session_start();
|
19 |
-
|
20 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
21 |
-
|
22 |
-
/************************************************
|
23 |
-
ATTENTION: Fill in these values! Make sure
|
24 |
-
the redirect URI is to this page, e.g:
|
25 |
-
http://localhost:8080/user-example.php
|
26 |
-
************************************************/
|
27 |
-
$client_id = '<YOUR_CLIENT_ID>';
|
28 |
-
$client_secret = '<YOUR_CLIENT_SECRET>';
|
29 |
-
$redirect_uri = '<YOUR_REDIRECT_URI>';
|
30 |
-
|
31 |
-
$client = new Google_Client();
|
32 |
-
$client->setClientId($client_id);
|
33 |
-
$client->setClientSecret($client_secret);
|
34 |
-
$client->setRedirectUri($redirect_uri);
|
35 |
-
$client->setScopes('email');
|
36 |
-
|
37 |
-
/************************************************
|
38 |
-
If we're logging out we just need to clear our
|
39 |
-
local access token in this case
|
40 |
-
************************************************/
|
41 |
-
if (isset($_REQUEST['logout'])) {
|
42 |
-
unset($_SESSION['access_token']);
|
43 |
-
}
|
44 |
-
|
45 |
-
/************************************************
|
46 |
-
If we have a code back from the OAuth 2.0 flow,
|
47 |
-
we need to exchange that with the authenticate()
|
48 |
-
function. We store the resultant access token
|
49 |
-
bundle in the session, and redirect to ourself.
|
50 |
-
************************************************/
|
51 |
-
if (isset($_GET['code'])) {
|
52 |
-
$client->authenticate($_GET['code']);
|
53 |
-
$_SESSION['access_token'] = $client->getAccessToken();
|
54 |
-
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
55 |
-
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
|
56 |
-
}
|
57 |
-
|
58 |
-
/************************************************
|
59 |
-
If we have an access token, we can make
|
60 |
-
requests, else we generate an authentication URL.
|
61 |
-
************************************************/
|
62 |
-
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
|
63 |
-
$client->setAccessToken($_SESSION['access_token']);
|
64 |
-
} else {
|
65 |
-
$authUrl = $client->createAuthUrl();
|
66 |
-
}
|
67 |
-
|
68 |
-
/************************************************
|
69 |
-
If we're signed in we can go ahead and retrieve
|
70 |
-
the ID token, which is part of the bundle of
|
71 |
-
data that is exchange in the authenticate step
|
72 |
-
- we only need to do a network call if we have
|
73 |
-
to retrieve the Google certificate to verify it,
|
74 |
-
and that can be cached.
|
75 |
-
************************************************/
|
76 |
-
if ($client->getAccessToken()) {
|
77 |
-
$_SESSION['access_token'] = $client->getAccessToken();
|
78 |
-
$token_data = $client->verifyIdToken()->getAttributes();
|
79 |
-
}
|
80 |
-
|
81 |
-
echo pageHeader("User Query - Retrieving An Id Token");
|
82 |
-
if (strpos($client_id, "googleusercontent") == false) {
|
83 |
-
echo missingClientSecretsWarning();
|
84 |
-
exit;
|
85 |
-
}
|
86 |
-
?>
|
87 |
-
<div class="box">
|
88 |
-
<div class="request">
|
89 |
-
<?php
|
90 |
-
if (isset($authUrl)) {
|
91 |
-
echo "<a class='login' href='" . $authUrl . "'>Connect Me!</a>";
|
92 |
-
} else {
|
93 |
-
echo "<a class='logout' href='?logout'>Logout</a>";
|
94 |
-
}
|
95 |
-
?>
|
96 |
-
</div>
|
97 |
-
|
98 |
-
<div class="data">
|
99 |
-
<?php
|
100 |
-
if (isset($token_data)) {
|
101 |
-
var_dump($token_data);
|
102 |
-
}
|
103 |
-
?>
|
104 |
-
</div>
|
105 |
-
</div>
|
106 |
-
<?php
|
107 |
-
echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/index.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
include_once "templates/base.php";
|
3 |
-
if (!isWebRequest()) {
|
4 |
-
echo "To view this page on a webserver using PHP 5.4 or above run: \n\t
|
5 |
-
php -S localhost:8080\n";
|
6 |
-
exit();
|
7 |
-
}
|
8 |
-
echo pageHeader("PHP Library Examples"); ?>
|
9 |
-
<ul>
|
10 |
-
<li><a href="simple-query.php">A query using simple API access</a></li>
|
11 |
-
<li><a href="user-example.php">A query for user data, using OAuth 2.0 authentication.</a></li>
|
12 |
-
<li><a href="batch.php">An example of combining multiple calls into a batch request</a></li>
|
13 |
-
<li><a href="service-account.php">A query using the service account functionality.</a></li>
|
14 |
-
<li><a href="simplefileupload.php">An example of a small file upload.</a></li>
|
15 |
-
<li><a href="fileupload.php">An example of a large file upload.</a></li>
|
16 |
-
<li><a href="idtoken.php">An example of verifying and retrieving the id token.</a></li>
|
17 |
-
<li><a href="multi-api.php">An example of using multiple APIs.</a></li>
|
18 |
-
</ul>
|
19 |
-
<?php echo pageFooter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/multi-api.php
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2011 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
include_once "templates/base.php";
|
18 |
-
session_start();
|
19 |
-
|
20 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
21 |
-
|
22 |
-
/************************************************
|
23 |
-
ATTENTION: Fill in these values! Make sure
|
24 |
-
the redirect URI is to this page, e.g:
|
25 |
-
http://localhost:8080/user-example.php
|
26 |
-
************************************************/
|
27 |
-
$client_id = '<YOUR_CLIENT_ID>';
|
28 |
-
$client_secret = '<YOUR_CLIENT_SECRET>';
|
29 |
-
$redirect_uri = '<YOUR_REDIRECT_URI>';
|
30 |
-
|
31 |
-
/************************************************
|
32 |
-
Make an API request on behalf of a user. In
|
33 |
-
this case we need to have a valid OAuth 2.0
|
34 |
-
token for the user, so we need to send them
|
35 |
-
through a login flow. To do this we need some
|
36 |
-
information from our API console project.
|
37 |
-
************************************************/
|
38 |
-
$client = new Google_Client();
|
39 |
-
$client->setClientId($client_id);
|
40 |
-
$client->setClientSecret($client_secret);
|
41 |
-
$client->setRedirectUri($redirect_uri);
|
42 |
-
$client->addScope("https://www.googleapis.com/auth/drive");
|
43 |
-
$client->addScope("https://www.googleapis.com/auth/youtube");
|
44 |
-
|
45 |
-
/************************************************
|
46 |
-
We are going to create both YouTube and Drive
|
47 |
-
services, and query both.
|
48 |
-
************************************************/
|
49 |
-
$yt_service = new Google_Service_YouTube($client);
|
50 |
-
$dr_service = new Google_Service_Drive($client);
|
51 |
-
|
52 |
-
|
53 |
-
/************************************************
|
54 |
-
Boilerplate auth management - see
|
55 |
-
user-example.php for details.
|
56 |
-
************************************************/
|
57 |
-
if (isset($_REQUEST['logout'])) {
|
58 |
-
unset($_SESSION['access_token']);
|
59 |
-
}
|
60 |
-
if (isset($_GET['code'])) {
|
61 |
-
$client->authenticate($_GET['code']);
|
62 |
-
$_SESSION['access_token'] = $client->getAccessToken();
|
63 |
-
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
64 |
-
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
|
65 |
-
}
|
66 |
-
|
67 |
-
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
|
68 |
-
$client->setAccessToken($_SESSION['access_token']);
|
69 |
-
} else {
|
70 |
-
$authUrl = $client->createAuthUrl();
|
71 |
-
}
|
72 |
-
|
73 |
-
/************************************************
|
74 |
-
If we're signed in, retrieve channels from YouTube
|
75 |
-
and a list of files from Drive.
|
76 |
-
************************************************/
|
77 |
-
if ($client->getAccessToken()) {
|
78 |
-
$_SESSION['access_token'] = $client->getAccessToken();
|
79 |
-
|
80 |
-
$dr_results = $dr_service->files->listFiles(array('maxResults' => 10));
|
81 |
-
|
82 |
-
$yt_channels = $yt_service->channels->listChannels('contentDetails', array("mine" => true));
|
83 |
-
$likePlaylist = $yt_channels[0]->contentDetails->relatedPlaylists->likes;
|
84 |
-
$yt_results = $yt_service->playlistItems->listPlaylistItems(
|
85 |
-
"snippet",
|
86 |
-
array("playlistId" => $likePlaylist)
|
87 |
-
);
|
88 |
-
}
|
89 |
-
|
90 |
-
echo pageHeader("User Query - Multiple APIs");
|
91 |
-
if (strpos($client_id, "googleusercontent") == false) {
|
92 |
-
echo missingClientSecretsWarning();
|
93 |
-
exit;
|
94 |
-
}
|
95 |
-
?>
|
96 |
-
<div class="box">
|
97 |
-
<div class="request">
|
98 |
-
<?php
|
99 |
-
if (isset($authUrl)) {
|
100 |
-
echo "<a class='login' href='" . $authUrl . "'>Connect Me!</a>";
|
101 |
-
} else {
|
102 |
-
echo "<h3>Results Of Drive List:</h3>";
|
103 |
-
foreach ($dr_results as $item) {
|
104 |
-
echo $item->title, "<br /> \n";
|
105 |
-
}
|
106 |
-
|
107 |
-
echo "<h3>Results Of YouTube Likes:</h3>";
|
108 |
-
foreach ($yt_results as $item) {
|
109 |
-
echo $item['snippet']['title'], "<br /> \n";
|
110 |
-
}
|
111 |
-
} ?>
|
112 |
-
</div>
|
113 |
-
</div>
|
114 |
-
<?php echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/service-account.php
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
session_start();
|
18 |
-
include_once "templates/base.php";
|
19 |
-
|
20 |
-
/************************************************
|
21 |
-
Make an API request authenticated with a service
|
22 |
-
account.
|
23 |
-
************************************************/
|
24 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
25 |
-
|
26 |
-
/************************************************
|
27 |
-
ATTENTION: Fill in these values! You can get
|
28 |
-
them by creating a new Service Account in the
|
29 |
-
API console. Be sure to store the key file
|
30 |
-
somewhere you can get to it - though in real
|
31 |
-
operations you'd want to make sure it wasn't
|
32 |
-
accessible from the webserver!
|
33 |
-
The name is the email address value provided
|
34 |
-
as part of the service account (not your
|
35 |
-
address!)
|
36 |
-
Make sure the Books API is enabled on this
|
37 |
-
account as well, or the call will fail.
|
38 |
-
************************************************/
|
39 |
-
$client_id = '<YOUR_CLIENT_ID>'; //Client ID
|
40 |
-
$service_account_name = ''; //Email Address
|
41 |
-
$key_file_location = ''; //key.p12
|
42 |
-
|
43 |
-
echo pageHeader("Service Account Access");
|
44 |
-
if (strpos($client_id, "googleusercontent") == false
|
45 |
-
|| !strlen($service_account_name)
|
46 |
-
|| !strlen($key_file_location)) {
|
47 |
-
echo missingServiceAccountDetailsWarning();
|
48 |
-
exit;
|
49 |
-
}
|
50 |
-
|
51 |
-
$client = new Google_Client();
|
52 |
-
$client->setApplicationName("Client_Library_Examples");
|
53 |
-
$service = new Google_Service_Books($client);
|
54 |
-
|
55 |
-
/************************************************
|
56 |
-
If we have an access token, we can carry on.
|
57 |
-
Otherwise, we'll get one with the help of an
|
58 |
-
assertion credential. In other examples the list
|
59 |
-
of scopes was managed by the Client, but here
|
60 |
-
we have to list them manually. We also supply
|
61 |
-
the service account
|
62 |
-
************************************************/
|
63 |
-
if (isset($_SESSION['service_token'])) {
|
64 |
-
$client->setAccessToken($_SESSION['service_token']);
|
65 |
-
}
|
66 |
-
$key = file_get_contents($key_file_location);
|
67 |
-
$cred = new Google_Auth_AssertionCredentials(
|
68 |
-
$service_account_name,
|
69 |
-
array('https://www.googleapis.com/auth/books'),
|
70 |
-
$key
|
71 |
-
);
|
72 |
-
$client->setAssertionCredentials($cred);
|
73 |
-
if ($client->getAuth()->isAccessTokenExpired()) {
|
74 |
-
$client->getAuth()->refreshTokenWithAssertion($cred);
|
75 |
-
}
|
76 |
-
$_SESSION['service_token'] = $client->getAccessToken();
|
77 |
-
|
78 |
-
/************************************************
|
79 |
-
We're just going to make the same call as in the
|
80 |
-
simple query as an example.
|
81 |
-
************************************************/
|
82 |
-
$optParams = array('filter' => 'free-ebooks');
|
83 |
-
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
|
84 |
-
echo "<h3>Results Of Call:</h3>";
|
85 |
-
foreach ($results as $item) {
|
86 |
-
echo $item['volumeInfo']['title'], "<br /> \n";
|
87 |
-
}
|
88 |
-
|
89 |
-
echo pageFooter(__FILE__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
google-api-php-client/examples/simple-query.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Google Inc.
|
4 |
-
*
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
* you may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at
|
8 |
-
*
|
9 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10 |
-
*
|
11 |
-
* Unless required by applicable law or agreed to in writing, software
|
12 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
-
* See the License for the specific language governing permissions and
|
15 |
-
* limitations under the License.
|
16 |
-
*/
|
17 |
-
include_once "templates/base.php";
|
18 |
-
echo pageHeader("Simple API Access");
|
19 |
-
|
20 |
-
/************************************************
|
21 |
-
Make a simple API request using a key. In this
|
22 |
-
example we're not making a request as a
|
23 |
-
specific user, but simply indicating that the
|
24 |
-
request comes from our application, and hence
|
25 |
-
should use our quota, which is higher than the
|
26 |
-
anonymous quota (which is limited per IP).
|
27 |
-
************************************************/
|
28 |
-
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
|
29 |
-
|
30 |
-
/************************************************
|
31 |
-
We create the client and set the simple API
|
32 |
-
access key. If you comment out the call to
|
33 |
-
setDeveloperKey, the request may still succeed
|
34 |
-
using the anonymous quota.
|
35 |
-
************************************************/
|
36 |
-
$client = new Google_Client();
|
37 |
-
$client->setApplicationName("Client_Library_Examples");
|
38 |
-
$apiKey = "<YOUR_API_KEY>"; // Change this line.
|
39 |
-
// Warn if the API key isn't changed.
|
40 |
-
if (strpos($apiKey, "<") !== false) {
|
41 |
-
echo missingApiKeyWarning();
|
42 |
-
exit;
|
43 |
-
}
|
44 |
-
$client->setDeveloperKey($apiKey);
|