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?

CommentFileSizeAuthor
#28 gdata-importer.patch5.7 KBstashlbai

Comments

soosa’s picture

Assigned: mandor78 » soosa

i will fix this very soon!

soosa’s picture

Status: Active » Fixed

Fixed!, thanks for reporting.

mandor78’s picture

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

soosa’s picture

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!

mandor78’s picture

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.

acushla’s picture

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

solutiondrop’s picture

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."

soosa’s picture

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!

gs12345’s picture

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?

R.Muilwijk’s picture

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?
   }
xjs’s picture

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?

Anonymous’s picture

+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.

Walt Esquivel’s picture

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.

solutiondrop’s picture

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

xjs’s picture

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

soosa’s picture

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.

Anonymous’s picture

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

soosa’s picture

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

xjs’s picture

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

solutiondrop’s picture

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
Walt Esquivel’s picture

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. :)

sanoju’s picture

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?

andypost’s picture

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

I change this line to

$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

       //$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]);
derjochenmeyer’s picture

#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...

andypost’s picture

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

derjochenmeyer’s picture

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
j0k3z’s picture

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

stashlbai’s picture

StatusFileSize
new5.7 KB

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.

andypost’s picture

Status: Active » Needs work

Patch from #28 works but retrives only 25 items
I think all because of this : 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?

stashlbai’s picture

The URL should read

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.

andypost’s picture

Status: Needs work » Reviewed & tested by the community

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

timbednar’s picture

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?

stashlbai’s picture

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.

romainlav’s picture

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

andypost’s picture

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

bowwowadmin’s picture

is this going to be committed the patch that is it works great. solved the issue

andypost’s picture

Main problem in requirements - php5 curl

fumanchu182’s picture

I applied that patch and received the following error:

Fatal error: Class 'GDataMailer' not found in /home/...sites/all/modules/dcl_importer/dcl_wrapper.inc on line 31
Page execution time was 381.22 ms.

This is how i applied the patch:

patch -b < gdata-importer.patch

This was done from the module root.

-Anthony

fumanchu182’s picture

fumanchu182’s picture

After looking at the whole thing there is a directory issue configuration. The original segment is:

function importGmail($login, $password) {
include ('scripts/importGData.class.php');
global $names;
global $emails;
$gmailer = new GDataMailer();

The include statement points to a file that is one directory below scripts. I don't know if this happened because of the patch but but I am going to leave it as part of the root directory and I have changed my include call to be :

include (drupal_get_path('module', 'dcl_importer').'/importGData.class.php');

This will allow you to move it to scripts eventually but just updating the string part of the include function.

-Anthony

abqaria’s picture

please update the module with latest patch

bflora’s picture

I'm getting the following error when I run a search for 100+ gmail contacts:

Call to a member function getAttribute() on a non-object in path/to/drupal/sites/all/modules/dcl_importer/scripts/importGData.class.php on line 97

it works fine when I don't specify how many results to return. Gives me this error when I do.

Here's the line in question:

$email = $mnode->getAttribute('address');

bflora’s picture

I got someone over on Stack Overflow to help me with this:
http://stackoverflow.com/questions/827343/whats-wrong-with-this-gmail-co...

hadsie’s picture

Status: Reviewed & tested by the community » Closed (fixed)

I'm marking this issue as "closed". The D5 version of this module is no longer being maintained. The original version had scripts that no longer worked and some that weren't compatible with the GPL. The D6 version is being developed now and is a complete re-write using the OpenInviter library. If you wish to submit a backport to D5 I'll be happy to add that to CVS. Please see the project page for more details.

plan9’s picture

Using the patch and tweak at #28 and #40 I am able to use the 5.x version. All imports work except MySpace - which I'm not interested in anyway.

I hope there will be a backport of the 6.x branch soon.
Thanks for this great module :)

G

smiletrl’s picture

Version: » 6.x-1.x-dev
Issue summary: View changes

There's one project for Gmail contact https://www.drupal.org/project/gmail_contact