/    Sign up×
Community /Pin to ProfileBookmark

PHP Gmail Contacts Import – Help

Hi

So I found a script on the internet that actually imports the contacts of your gmail once you provide a correct gmail username / password.

I have attached 2 zip files with this post.

[B]working_example.zip[/B] – Contains the working example of the script. Returns the contacts in an array() format on success.

[B]not_working_example.zip[/B] – I wanted to implement this script using class. So I went ahead and wrapped the code in a class and created an instance of the class, but when I tried to call the method, it generated the following error:

[CODE]Warning: curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:not_working_examplegmail.api.include.php on line 36

Warning: curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:not_working_examplegmail.api.include.php on line 65[/CODE]

Please, if anyone can help me figuring out the issue, I will be greatful.

I am guessing this has something to do with scopes in OOP, but not sure what….pls help ?

Many thanks

[upl-file uuid=70629ec2-5e3b-4b78-b48d-501ef6239d04 size=2kB]not_working_example.zip[/upl-file]

[upl-file uuid=e2fc76d5-5b95-4c72-a4a8-48f6fafb48e4 size=2kB]working_example.zip[/upl-file]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 28.2009 — At a quick glance I'm not sure why that specific error would be raised, but in the big picture, simply wrapping it in a class does not really gain you anything: that does not in and of itself make it object-oriented -- it just makes it wrapped in a class. The use of "global" has no place in an object-oriented class function. You probably instead should, for instance, be referencing [b]$this->location[/b] in the functions rather than a global [b]$location[/b], the latter putting its scope outside of the class/object.

In any case, I'm not crazy about [i]any[/i] function that uses "global", so even if you just stuck with the original procedural function (and if it works, why "fix" it?), I'd want to rework it to pass those variables as parameters (by reference if needed) rather than using the dreaded [b]global[/b] command. ?
Copy linkTweet thisAlerts:
@phantom007authorNov 28.2009 — Hi

Thanks for the reply. I got the answer. I needed to replace that line with this one..


curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'read_header'));
×

Success!

Help @phantom007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...