Hacking Gmail

(Grace) #1

Chapter 7 — Gmail Libraries 119


How to Use It


Gmailer provides a series of methods that can be used to log in to Gmail and per-


form the usual functions. Table 7-1 gives the complete rundown of the methods.


Table 7-1 Gmailer’s Methods

Method Function

void setSessionMethod To set the session handling method before connect. If you want
(GM_CONSTANT method) PHP to handle it with cookies, set it to GM_USE_PHPSESSION|
[0.6.4] GM_USE_COOKIE; if you want PHP to handle it but without
using cookies, set it to !GM_USE_COOKIE|GM_USE_
PHPSESSION; if you do not want PHP to handle it, set it to
GM_USE_COOKIE|!GM_USE_PHPSESSION. It will set to
GM_USE_PHPSESSION|GM_USE_COOKIEby default.
void setLoginInfo To set the login information before connect.
string name,
string password,
int GMT_timezone)
void setProxy(string To set the proxy information if necessary. If your proxy server
hostname, string does not require login, set both username and password to “”
username, string
password) [0.6.4]
bool connect() To connect to Gmail. It will use header()to set cookies at the
client-side browser. So you shouldn’t output anything before
calling this method, or use connectNoCookie()otherwise. It
returns 1 if it succeeds, 0 otherwise.
bool connectNoCookie() To connect to Gmail without storing any cookies at the client-side
browser. It returns 1 if it succeeds, 0 otherwise.
bool isConnected() To check if connected.
bool fetch(string query)To fetch the URL query result from Gmail. It is intended to be
used internally (private method). Use fetchBox()instead.
bool fetchBox To fetch a result from Gmail by given:
GM_CONSTANT type, type: Gmailer constant, such as GM_LABEL.
string box, int position) box: name of box (such as Inbox, your_label)
position: cursor for paged result.
bool fetchContact() To fetch the contact list.

Continued
Free download pdf