Google Community
Latest Forums Rules Resources
Custom Search

Go Back   Google Community > Webmaster Forums > Web Design, Coding & Programming Forum

GoogleCommunity Sponsor

Reply
 
LinkBack Thread Tools Display Modes
Old 02-01-2007, 05:43 PM   #1 (permalink)
Noogle
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
aussie123 is on a distinguished road
PHP Help Needed

I was hoping someone here experienced with PHP and Gmail can help me find this error in my Gmail Contacts Importer script.
It was working just fine a while ago but now I get the following error after i enter the username and password of my Gmail user account and press the submit button.

Warning: Invalid argument supplied for foreach() in /home/mysite/public_html/louis/gmail.php on line 117

The Following is the code on line 117

foreach ($snapshot2->contacts as $item2) {


The following is the full code in the PHP file that contains this error.

<?php
require("libgmailer.php");
if($_POST['login'])
{
$php_userid = $_POST['login'];
$php_password = $_POST['passwd'];
$sender = $_POST['login'];

$gmail_acc = $php_userid;
$gmail_pwd = $php_password;
$gmail_tmz = "+2";
$gm = new GMailer();
$gm->setLoginInfo($gmail_acc,$gmail_pwd,$gmail_tmz);
if ($gm->connect()) {
showList($php_userid,$php_password,$sender);
}
else{
login_form("ERROR: Invalid User Name or password");
}

}
else
{
login_form("");
}
////////////////////////////////////////////////////////////////////////////////////////////////
function login_form($errcode)
{
?>
<html>
<head>
<title>Google Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="400" id="AutoNumber1" bgcolor="#CCCCFF">
<tr>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="msn.php">MSN</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="yahoomail.php">Yahoo!</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="hotmail.php">Hotmail</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="gmail.php">GMail</a></b></font></div>
</td>
</tr>
</table>
<div align="center" style="border: #000000; border-style: solid; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; width:400px;">
<form method="post" action="gmail.php" autocomplete=on name="login_form" >
<table id="yreglgtb" summary="form: login information">
<tbody>
<tr>
<td colspan="2">
<div align="center">
<p><font face="Arial, Helvetica, sans-serif" size="5"><b><font size="4">Import GMail Contacts</font></b></font></p>
<p><img src="gmail.gif"></p>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="400" id="AutoNumber1">
<tr>
<td width="100%">
<p><font face="Arial, Helvetica, sans-serif" size="2"><b>Note: Privacy Statement-
Your ID and Password is not saved and will be cleared. All this does is
invite your contact list to check out this site. It's 100% safe to use.</b></font></p>
<p><font face="Arial, Helvetica, sans-serif" size="2">Please be patient
after clicking the invite button <b>once</b>. <b>Note:</b> There are tick
boxes beside the e-mail addresses - if you wish not to invite a particular
person / e-mail address then un-tick it. </font></p>
</td>
</tr>
</table></td>
</tr>
<tr>
<th><label for="username">Gmail Address:</label></th>
<td><input name="login" id="login" value="" size="17" class="yreg_ipt" type="text"></td>
</tr>
<tr>
<th><label for="passwd">Password:</label></th>
<td><input name="passwd" id="passwd" value="" size="17" class="yreg_ipt" type="password"></td>
</tr>
<tr><td colspan="2"><font face ="Arial" size="2" color="red"><b><?echo $errcode; ?></b></font></td></tr>
</tbody></table>
<input value="Sign In" type="submit">
</form>
</div>
</body>
</html>
<?
}
function showList($theUser,$thePassword,$theSender){
$gmail_tmz2 = "+2";
$retString = "";
$gm2 = new GMailer();
$gm2->setLoginInfo($theUser,$thePassword,$gmail_tmz2) ;
$gm2->connect();
$gm2->fetchBox(GM_CONTACT, "all", 0);
$snapshot2 = $gm2->getSnapshot(GM_CONTACT);
$myfile = "addresses.txt";
$fh = fopen($myfile, 'a');
foreach ($snapshot2->contacts as $item2) {
$retString .= "<tr><td><input name=\"addresses[]\" value=\"" . $item2["email"] . "\" checked=\"checked\" type=\"checkbox\"></td><td>" . $item2["email"]. "</td>";

fwrite($fh, $item2["email"] . "\n");
}
?>
<html>
<head>
<title>Google Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function togglechecked(){
for (var i = 0; i < document.inviteform.elements.length; i++) {
var e = document.inviteform.elements[i];
if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {
e.checked = document.inviteform.allbox.checked;
}
}
}
function toggleselect(){
document.inviteform.allbox.checked = !document.inviteform.allbox.checked;
togglechecked();}
</script>
</head>
<body>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="400" id="AutoNumber1" bgcolor="#CCCCFF">
<tr>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="msn.php">MSN</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="yahoomail.php">Yahoo!</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="hotmail.php">Hotmail</a></b></font></div>
</td>
<td width="25%">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><a href="gmail.php">GMail</a></b></font></div>
</td>
</tr>
</table>
<div align="center" style="border: #000000; border-style: solid; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; width:400px;">
<form method="post" action="gmail2.php" autocomplete=on name="inviteform" >
<table id="yreglgtb" summary="form: login information" border="0" cellspacing="4" cellpadding="4">
<tbody>
<tr>
<td colspan="2">
<div align="center"><p><font face="Arial, Helvetica, sans-serif" size="5"><b><font size="4">Import GMail Contacts</font></b></font></p>
<p><img src="gmail.gif"></p>
</div>
</td>
</tr>
<tr>
<td bgcolor="#cccccc"><input name="allbox" id="allbox" value="nothing" onclick="togglechecked()" checked="checked" type="checkbox"></td>
<td bgcolor="#cccccc"><b>E-Mail Address</b>
<input type="hidden" name="sender" value="<? echo $theSender; ?>"></td>
</tr>
<?
echo $retString;
?>
<tr><td><input name="allbox2" value="nothing" onclick="toggleselect()" checked="checked" type="checkbox"></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td></tr>
</tbody></table>
<input value="Send Invitation" type="submit">
</form>
</div>
</div>
</body>
</html>
<?
}
?>


Any help here would be greatly appreciated.
My email address is roxboy_@hotmail.com if you want to contact me directly.

Regards
Aussie123
aussie123 is offline   Reply With Quote
 
Sponsored Links
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed shahidramzan General Discussion 0 10-10-2006 12:57 AM
Your help needed! samimiybala Google AdWords & AdSense Forum 2 05-14-2006 08:11 AM
A little help needed ... Gizmo Web Design, Coding & Programming Forum 3 09-29-2005 12:41 PM
Help Needed RatPat Web Design, Coding & Programming Forum 3 09-22-2005 03:13 AM
Sig Needed RatPat Graphics Design Forum 8 05-29-2005 04:50 PM


All times are GMT -8. The time now is 08:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© 2004–2007 Google Community