Gmail contacts discussion

mandor78 - January 11, 2008 - 15:41
Project:Drupal Contact List Importer
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:soosa
Status:patch (reviewed & tested by the community)
Description

Hi.
When i am trying to import contact list from gmail i have this :
warning: Invalid argument supplied for foreach() in .....sites\all\modules\dcl_importer\dcl_wrapper.inc on line 40.
How can i fix it?

#1

soosa - January 11, 2008 - 23:26
Assigned to:mandor78» soosa

i will fix this very soon!

#2

soosa - January 12, 2008 - 00:22
Status:active» fixed

Fixed!, thanks for reporting.

#3

mandor78 - January 12, 2008 - 10:45

how can i check it,i downloaded module today but its still not working...

#4

soosa - January 12, 2008 - 15:19

try to download it again, most probably you have downloaded the out dated version! since generating tarballs in drupal project's page takes a while, so just try downloading it again!

#5

mandor78 - January 13, 2008 - 14:48

now i have this new warning:
warning: Invalid argument supplied for foreach() in ....\sites\all\modules\dcl_importer\dcl_wrapper.inc on line 49.
I think the bug only when the login name looks like fridman.vlad, if i use login looks like one word its working.

#6

acushla - January 21, 2008 - 14:15
Status:fixed» active

Hi,

I tried to install the module by taking the release that you have made on 17th January. But still I ma getting the error:

"warning: Invalid argument supplied for foreach() in mysitepath/drupal/modules/dcl_importer/dcl_wrapper.inc on line 49."

I am unable to import any contacts from gmail. Yahoo works fine. Please help!

Thanks in advance,

Rajat

#7

dividespace - January 21, 2008 - 23:00

Just to confirm, I am also getting the same warning for gmail only using both single word email addresses and two word email addresses (e.g., first.second@gmail.com). I am running PHP5 and the lastest Drupal Dev version

"warning: Invalid argument supplied for foreach() in mysitepath/drupal/modules/dcl_importer/dcl_wrapper.inc on line 49."

#8

soosa - February 2, 2008 - 22:22

i really cannot reproduce this issue, i have tested gmail importer with 7 gmail accounts and they are all working just fine including accounts that start with (*.*) and single word accounts as well!

#9

grendelshitsuren - February 4, 2008 - 20:49

I have downloaded the current stable tonight and can confirm that
modules/dcl_importer/dcl_wrapper.inc on line 49
happens with googlemail.com accounts with the form of "abc.abc"
I have over 1000 contacts though maybe that's also a problem?

#10

R.Muilwijk - February 5, 2008 - 13:17

The problem is that the function getAddressbook used in that line:

   $contacts = $gmailer->getAddressbook($login, $password);

does not always return an array. There for it is not possible to do a foreach. The code should be something like:

   if ($contacts = $gmailer->getAddressbook($login, $password) && is_array($contacts)) {
     foreach($contacts as $name => $email) {
       $names[]  = $name;
       if ($str_pos = strpos($email, '-')) {
        // $email = trim(substr($email, 0, $str_pos));
       }
       $emails[] = $email;
     }
   }
   else {
     // why am I throwing an error?
   }

#11

xjs - February 9, 2008 - 01:38

Yes, this removes the warning. However, I am still getting this: "Gmail login information is invalid or your contact list is empty,..."
And my contact list is not empty. Anyone has the same problem?

#12

txcrew - February 11, 2008 - 17:19

+1 I am also having this problem:

warning: Invalid argument supplied for foreach() in /home/cultural/public_html/sites/all/modules/dcl_importer/dcl_wrapper.inc on line 49.

Gmail login information is invalid or your contact list is empty, if you are sure that your contact list is not empty then please try again and make sure that you have typed the correct login information.

#13

Walt Esquivel - February 15, 2008 - 21:55

I had the same exact problem as txcrew in #12 with the same exact error verbiage regarding the infamous line 49.

Although not all of my Gmail contacts have email addresses (some are just names with phone numbers and/or postal addresses), I have 963 contacts in my Gmail address book, so I know it's not empty. I tried getting this module to import both my Gmail and Yahoo contacts and both failed.

I'm on a shared host at DreamHost.

I'm using Drupal 5.7, Linux, Apache/2.0.61 (Unix), MySQL 5.0.24a, PHP 5.2.3, and dcl_importer-5.x-1.x-dev.

This issue seems to be a duplicate of http://drupal.org/node/209548, which is a line 49 error.

#14

dividespace - February 15, 2008 - 03:19

My problem is with gmail only, I have tested a yahoo.com account and that works fine.

Anyway, I did insert "error_reporting(E_ALL);" into the dcl_wrapper.inc file as suggested at http://drupal.org/node/209548. I did not get any PHP errors or notices in my error_log.
regarding troubleshooting the cookie directory as suggested at http://drupal.org/node/209548, the importGmail.class.php file doesn't seem to contain a $cookieFile or point to /var/tmp/ so I wasn't able to test for cookie directory problems for gmail, but at least I know that yahoo works so it probably isn't a problem with the cookie in my situation.

Thanks

#15

xjs - February 15, 2008 - 20:06

Yes, yahoo works for me too, but not gmail. Haven't tested with others since I don't have account with them :)

#16

soosa - February 15, 2008 - 21:49

i suspect that the common factor between all the threads above is "the shared host", gmail importer is working perfectly with my installation and everything is just fine with the other importers, since its all working fine at least in my own server "i am running the importers in a dedicated server" then that would mean that there is something wrong "disabled/enabled" with the server configuration
if anyone has any clue why shared hosts doesn't work all the time with gmail specifically then i would thankful for any advice to be mentioned here.

#17

txcrew - February 16, 2008 - 00:43

I am on a dedicated server. But that is not to say I don't have something "disabled/enabled". But I don't know what that something could be.

txcrew

#18

soosa - February 16, 2008 - 02:08

could you please post your php.ini settings so we can take a look at it?

#19

xjs - February 16, 2008 - 02:16

I have a local version which runs on my own server. My live version runs a VPS (php4). My local version has php 5 with mostly default setting except for:
;max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_execution_time = 1000 ; Maximum execution time of each script, in seconds

;max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
max_input_time = 1000 ; Maximum amount of time each script may spend parsing request data

memory_limit = 48M ; Maximum amount of memory a script may consume

#20

dividespace - February 18, 2008 - 20:15

I'm also on a dedicated server, but like txcrew said above, I may have something "disabled/enabled". I'm using PHP Version 5.2.4.

Here is the PHP build information:

System Linux webserver.XXXXXX.XXX 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:28:02 EDT 2006 i686
Build Date Oct 23 2007 01:36:47
Configure Command './configure' '--libdir=/usr/lib' '--with-pic' '--prefix=/usr/local/php5' '--exec-prefix=/usr/local/php5' '--program-suffix=5' '--enable-fastcgi' '--enable-bcmath' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mbstr-enc-trans' '--enable-mbregex' '--enable-exif' '--with-gd' '--enable-gd-native-ttf' '--without-gdbm' '--enable-ftp' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-png' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-pspell' '--with-iconv' '--with-xml' '--with-dom' '--with-pcre-regex' '--with-expat-dir=/usr' '--with-curl' '--with-mcrypt' '--enable-mbstring' '--enable-magic-quotes' '--with-mysql=/usr' '--with-mysqli' '--with-openssl' '--with-snmp' '--enable-memory-limit' '--enable-shmop' '--enable-force-cgi-redirect' '--enable-discard-path' '--with-pear=/usr/share/pear' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-ldap' '--enable-sockets' '--enable-sysvem' '--enable-sysvhsm' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-ttf' '--with-bz2' '--with-layout=GNU' '--enable-pic' '--with-db4=/usr' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-zlib'
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/php5/etc
Loaded Configuration File (none)
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*

And here is my configuration:

Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors On On
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 6135 no value
expose_php On On
extension_dir /usr/lib/20060613 /usr/lib/20060613
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/share/pear .:/usr/share/pear
log_errors Off Off
log_errors_max_len 1024 1024
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_input_nesting_level 64 64
max_input_time -1 -1
memory_limit 128M 128M
open_basedir no value no value
output_buffering 0 0
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv On On
register_globals Off Off
register_long_arrays On On
report_memleaks On On
report_zend_debug On On
safe_mode Off Off
safe_mode_exec_dir /usr/local/php/bin /usr/local/php/bin
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir no value no value
user_dir no value no value
variables_order EGPCS EGPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.ze1_compatibility_mode Off Off

#21

Walt Esquivel - April 9, 2008 - 03:49

I came back here after having posted #13 above to see if this critical issue had been fixed, but it looks like both the critical issue described above and what appears to be its duplicate at http://drupal.org/node/209548 haven't been worked on since mid-February.

Is there anyone that can fix this critical issue and have the patch applied to the dev version so non-coders like me can easily download it?

Any assistance appreciated. Thank you. :)

#22

sanoju - April 17, 2008 - 08:21

Hi,

I've downloaded the module a couple days ago, and encountered the same "line 49" error.
The problem disappears when I change my Gmail's language setting to English.
Line 134 of importGmail.class.php says

$tempname = split('All Contacts',$html2,2);

but the "All Contacts" part changes depending on Gmail's language setting.
For example, if the language is set to Japanese, the string is "すべての連絡先" rather than "All Contacts".
In this case, changing the code to

$tempname = split('すべての連絡先',$html2,2);

allowed me to import the contacts.

Can anyone come up with a solution that works for any language setting?

#23

andypost - May 14, 2008 - 18:03

There's a API http://code.google.com/apis/contacts/

I change this line to

<?php
$tempname
= split('<input type="submit" name="nvp_bu_sc"',$html2,2);
?>

Now it woks for russian language but at the end of list I see a garbage from bottom so I add another split and change index

<?php
      
//$tempname = split('<b>All&nbsp;Contacts</b>',$html2,2);
      
$tempname = split('<input type="submit" name="nvp_bu_sc"', $html2, 2);
      
$tempname = split('<input type="submit" name="nvp_bu_comp"', $tempname[1], 2);

      
preg_match_all('/<b>([^\<]*)/s',$tempname[0],$name);
      
$tempemail = preg_replace('/<b>([^\<]*)/s','',$tempname[0]);
?>

#24

derjochenmeyer - May 14, 2008 - 16:32

#23 thats a good approach but it does not return a clean contact list. Comments and postal adresses are included sometimes.

The Google DATA API is an option, but it requires the user to first login to his/her google account. Then an authorization token is received. This makes the process safer for the user but also more inconvenient.

http://code.google.com/apis/contacts/developers_guide_protocol.html

But different language settings are obviously a problem that is not easy to handle, right? To use the API is the cleanest method...

#25

andypost - May 15, 2008 - 11:28
Title:Gmail problem» Gmail contacts discussion

Take a look at http://code.google.com/apis/contacts/developers_guide_protocol.html#clie...
Suppose this type of auth is preferred (we have a email & pass)

After that we can query a contacts feed as described
http://code.google.com/apis/contacts/developers_guide_protocol.html#retr...

Then xml parsing

#26

derjochenmeyer - May 15, 2008 - 12:58

wow, i completely overread this...

so we need to make a request like this

https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE
  &Email=USERNAME@gmail.com
  &Passwd=PASSWORD
  &service=cl
  &source=Gulp-CalGulp-1.05

we receive an Authentication Token which we then have to include as header information in requesting the contact list...

Authorization: GoogleLogin auth=yourAuthToken

#27

j0k3z - May 15, 2008 - 20:35

has this been fixed? Just downloaded the module and get this error...

#28

stashlbai - June 3, 2008 - 18:58

We have written a GData contacts importer using the API mentioned above. It's attached as a patch. It works for us and your mileage may vary. In particular, we take advantage of PHP5 and the DOM extensions.

The dcl_wrapper.inc script has the changes to load in the new class instead of the old. The new class does not depend on baseclass.php.

The dcl_importer.module has changes to pass through the entire email address when querying GMail. This allows GoogleApps users to also get their contacts, even though their username is not of the form username@gmail.com.

AttachmentSize
gdata-importer.patch5.7 KB

#29

andypost - June 3, 2008 - 23:24
Status:active» patch (code needs work)

Patch from #28 works but retrives only 25 items
I think all because of this :

<?php
static $url_Feed = 'http://www.google.com/m8/feeds/contacts/default/thin';
?>

I've tried to change it as proposed http://code.google.com/apis/contacts/developers_guide_protocol.html#retr...
to contacts/default/full and contacts/[myinbox]%40gmail.com/full but unsuccessfully - only 25 contacts

Another question if we have a name of contact why not to use user name <email> form of contacts?

#30

stashlbai - June 4, 2008 - 17:33

The URL should read

<?php
static $url_Feed = 'http://www.google.com/m8/feeds/contacts/default/thin?max-results=100';
?>

if you want 100. You can't ask for "all" but you can ask for 65535, for example. See http://code.google.com/apis/contacts/reference.html#Parameters for more information.

This leads to all kinds of other things to discuss. What do you do with 100 contacts on the invite form? Why does the invite module discard the name information? Wouldn't it be nice for this to work like LinkedIn where you get a list of potential contacts and then get to choose (check box, drag and drop, etc) which subset to work with?

What's the future of this module? It seems to have gone dormant. I don't know that we would be in a position to step in and take on this whole module; right now, what we can provide is the patch. If someone can pick this module up and run with it we can help with functionality, rewriting, etc. for the Google part.

#31

andypost - June 4, 2008 - 19:35
Status:patch (code needs work)» patch (reviewed & tested by the community)

Thanks a lot! A number of users is optional.
But it starts a new interesting discussion...

#32

timbednar - June 6, 2008 - 18:39

Thanks so much for the work here -- I believe I'm getting an error with the above patch and new GData contacts importer class. Any help for those of us who are not running php5?

#33

stashlbai - June 9, 2008 - 14:13

timbednar,

You've exposed exactly why we can't fully take on supporting module code - at this time, we don't have the resources to support the code/patches/testing for PHP != 5 or Drupal != 5. If you can reproduce the error for (PHP, Drupal) == (5, 5) then we can take a look.

At this time, we're working on building out our sites' functionality by stitching together (and patching where necessary) contrib modules, while also writing custom module/theme code. Once we go into maintenance mode on this version of our site(s), then we will see what modules if any we can contribute back or adopt, knowing that fully taking on a module basically means supporting all combinations of PHP(4, 5) and Drupal(5, 6, 7) etc.

With that said: if you can post the error you're getting while applying (or running) the patch, we might be able to give a suggestion; or someone else might recognize the issue and give an answer.

#34

romainlav - July 6, 2008 - 20:52

always have error :(

Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /drupal-5.7/modules/dcl_importer/scripts/importGData.class.php on line 5

#35

andypost - July 22, 2008 - 20:27

There's another discussion http://groups.drupal.org/node/9824

 
 

Drupal is a registered trademark of Dries Buytaert.