PHP Gmail Contacts Import - Help

Discussion in 'PHP' started by theextelligence, Nov 28, 2009.

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

    working_example.zip - Contains the working example of the script. Returns the contacts in an array() format on success.

    not_working_example.zip - 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:

    Warning:  curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:\not_working_example\gmail.api.include.php on line 36
    
    Warning:  curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in D:\not_working_example\gmail.api.include.php on line 65
    Code (markup):

    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
     

    Attached Files:

    theextelligence, Nov 28, 2009 IP
  2. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do a google search for 'CURLOPT_HEADERFUNCTION inside objects' and then look at the stuff on the experts-exchange site. basically it says curl doesn't allow callbacks within objects. so try putting the callback function outside of the class as suggested.
     
    szalinski, Nov 28, 2009 IP
  3. theextelligence

    theextelligence Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    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'));
     
    theextelligence, Nov 28, 2009 IP