Go to Post Don't you just wish life had a redo button? - DHarris [more]
Home
Go Back   Chief Delphi > Other > Chit-Chat
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-07-2005, 23:27
MrToast's Avatar
MrToast MrToast is offline
I named Greg Needel's cat!
AKA: Dave DeLong
no team (Rhode Warriors)
Team Role: Alumni
 
Join Date: Mar 2004
Rookie Year: 2004
Location: RI, now UT
Posts: 326
MrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud of
Send a message via AIM to MrToast
libgmailer experience?

Hi all,

I'm trying to set up a page on my site to use libgmailer, an open source set of PHP classes for remotely connecting to Gmail.

What I'm trying to do is figure out how many invitations I have left. Unfortunately, nothing's working.

Here's the code of my main "gmail.php" file:
Code:
<?php
	require_once("libgmailer.php");
	$gmail = new GMailer();
	$gmail->setLoginInfo("mrtoast@gmail.com","mypassword",0);
	$gmail->connect();
	$gmail->fetchBox(GM_STANDARD, "inbox", 0);
	$info = $gmail->getInfo();
	var_dump($info);
	$gmail->disconnect();
?>
At first you may think "Oh, well your obvious problem is that there's no such function as "getInfo()". And you're right. Except that I've picked apart the code for Gallina, a gmail-based blogging system and added the getInfo function to libgmailer:
Code:
function getInfo() {
	$snapshot = $this->getSnapshot(GM_STANDARD);
	$info = array();
	if ($snapshot) {
		$info["quota"]["MB"] = $snapshot->quota_mb;
		$info["quota"]["Percentage"] = $snapshot->quota_per;
		$info["invitations"] = $snapshot->have_invit;
		$info["labels"] = $snapshot->label_list;
		$info["total"] = $snapshot->box_total;
	}
	return $info;
}
Unfortunately, the var_dump is producing nothing but this:
Code:
array(4) {
  ["quota"]=>
  array(2) {
    ["MB"]=>
    NULL
    ["Percentage"]=>
    NULL
  }
  ["invitations"]=>
  NULL
  ["labels"]=>
  NULL
  ["total"]=>
  NULL
}
If anyone has any experience with this, I'd love for someone to help me figure out where I'm screwing up. Feel free to IM me, email, post here, whatever.

Thanks!

Dave
__________________
(#121, 2004) Archimedes semi-finalists with 237 and 386! I had an awesome time guys, and thanks for the hat!
(#121, 2004) BC5 semi-finalists with 190 and 1027! Awesome time! We went further than I thought we could! Thanks for all your help w/ our transmission!
(#121, 2005) Galileo quarter-finalists with 47 and 203! Thanks for all your support through the stress!
------------------------------
If it moves and it shouldn't, use duct tape.
If it doesn't move and it should, use WD-40
------------------------------
"It'll all work out in the end, and if it doesn't, it's not the end." - Jeff Bullock
Reply With Quote
  #2   Spotlight this post!  
Unread 05-07-2005, 23:46
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: libgmailer experience?

Quote:
Originally Posted by MrToast
Code:
function getInfo() {
	$snapshot = $this->getSnapshot(GM_STANDARD);
	$info = array();
	if ($snapshot) {
		$info["quota"]["MB"] = $snapshot->quota_mb;
		$info["quota"]["Percentage"] = $snapshot->quota_per;
		$info["invitations"] = $snapshot->have_invit;
		$info["labels"] = $snapshot->label_list;
		$info["total"] = $snapshot->box_total;
	}
	return $info;
}
When you call getSnapshot, your only have the $type parameter set (GM_STANDARD), but in the class GMailSnapshot constructor it also has a $raw parameter. There is an if statement which decides whether or not to set $this->have_invit;
Code:
if (isset($raw["i"][1])) $this->have_invit = $raw["i"][1];
But, $raw isn't set. Maybe try something like
Code:
function getInfo() {
	$raw = array(
		  "i" => array(TRUE),
		  "gn" => array(TRUE),
		  "v" => array(TRUE)
		);
	$snapshot = $this->getSnapshot(GM_STANDARD);
	$info = array();
	if ($snapshot) {
		$info["quota"]["MB"] = $snapshot->quota_mb;
		$info["quota"]["Percentage"] = $snapshot->quota_per;
		$info["invitations"] = $snapshot->have_invit;
		$info["labels"] = $snapshot->label_list;
		$info["total"] = $snapshot->box_total;
	}
	return $info;
}
That array setup may be fubar, as I've never dealt with multi-dimensional arrays in this sense...

EDIT (Again): Just looked over the code, and $this->have_invit is set from the array put in as a parameter, so I don't think you can get the amount of invites from calling this function =(

Maybe some creative use of sockets and regular expression functions would let you parse the info out?

__________________
http://www.mikesorrenti.com/

Last edited by Mike : 05-07-2005 at 23:55.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-07-2005, 23:58
MrToast's Avatar
MrToast MrToast is offline
I named Greg Needel's cat!
AKA: Dave DeLong
no team (Rhode Warriors)
Team Role: Alumni
 
Join Date: Mar 2004
Rookie Year: 2004
Location: RI, now UT
Posts: 326
MrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud of
Send a message via AIM to MrToast
Re: libgmailer experience?

I think that $raw IS set, because I call:
$gmail->fetchBox(GM_STANDARD, "inbox", 0);

Looking through this, we see it fires:
Code:
$this->fetch($q);
And then looking at the fetch function we see the line:
Code:
$this->raw = $packets;
So $raw is getting set. But I've just found something interesting...
In this same fetch function, the data returned from GMail is in the $inbox variable. I shot it out to HTML via:
Code:
echo "<textarea>".$inbox."</textarea>";
This is what's in the textarea:
Code:
<script>top.location="https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl";</script>
Any idea what's up with that?

Thanks!

Dave
__________________
(#121, 2004) Archimedes semi-finalists with 237 and 386! I had an awesome time guys, and thanks for the hat!
(#121, 2004) BC5 semi-finalists with 190 and 1027! Awesome time! We went further than I thought we could! Thanks for all your help w/ our transmission!
(#121, 2005) Galileo quarter-finalists with 47 and 203! Thanks for all your support through the stress!
------------------------------
If it moves and it shouldn't, use duct tape.
If it doesn't move and it should, use WD-40
------------------------------
"It'll all work out in the end, and if it doesn't, it's not the end." - Jeff Bullock
Reply With Quote
  #4   Spotlight this post!  
Unread 06-07-2005, 00:09
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: libgmailer experience?

Try echo'ing out $this->raw after it's set in fetch()
__________________
http://www.mikesorrenti.com/
Reply With Quote
  #5   Spotlight this post!  
Unread 06-07-2005, 00:14
MrToast's Avatar
MrToast MrToast is offline
I named Greg Needel's cat!
AKA: Dave DeLong
no team (Rhode Warriors)
Team Role: Alumni
 
Join Date: Mar 2004
Rookie Year: 2004
Location: RI, now UT
Posts: 326
MrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud ofMrToast has much to be proud of
Send a message via AIM to MrToast
Re: libgmailer experience?

It's an empty array:
Code:
array(0) { }
Grrrrr.... time to contact the developer....

Dave
__________________
(#121, 2004) Archimedes semi-finalists with 237 and 386! I had an awesome time guys, and thanks for the hat!
(#121, 2004) BC5 semi-finalists with 190 and 1027! Awesome time! We went further than I thought we could! Thanks for all your help w/ our transmission!
(#121, 2005) Galileo quarter-finalists with 47 and 203! Thanks for all your support through the stress!
------------------------------
If it moves and it shouldn't, use duct tape.
If it doesn't move and it should, use WD-40
------------------------------
"It'll all work out in the end, and if it doesn't, it's not the end." - Jeff Bullock
Reply With Quote
  #6   Spotlight this post!  
Unread 06-07-2005, 00:21
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: libgmailer experience?

Quote:
Originally Posted by MrToast
It's an empty array:
Code:
array(0) { }
Grrrrr.... time to contact the developer....

Dave
Yeah, it'd take a while for someone to learn how he structured the code. Odds are it's being set somewhere else as well.
__________________
http://www.mikesorrenti.com/
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
worst experience mike pawlak Chit-Chat 15 06-12-2004 07:04
Your Worst FIRST experience Richomundo General Forum 54 18-07-2004 23:02
A testimony to my unique FIRST experience: Ken Leung General Forum 22 14-04-2004 20:45
FIRST was an awesome experience for our rookie team (team overview) TheGreatPF General Forum 6 05-04-2004 00:15
2003 IRI: A driver's last hurrah or a new rookie driver's experience? Amanda Morrison Off-Season Events 14 23-05-2003 17:39


All times are GMT -5. The time now is 06:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi