1

Import Contacts of Yahoo using php. Is there any sample code available anywhere .


Import Contacts of Yahoo using php. Is there any sample code available anywhere . Please help

by
12 Replies
  • Just provide these three parameter to function and these will print all yahoo contacts for you..

    function contactlist()
    {
            $oauth_access_token = ' ';
        $oauth_token_secret = ' ' ;
        $session_id     = ' ' ;
        //prepare url
        $url = 'http://developer.messenger.yahooapis.com/v1/contacts';
        $url .= '?oauth_consumer_key='. CONSUMER_KEY;
        $url .= '&oauth_nonce='. uniqid(rand());
        $url .= '&oauth_signature='. CONSUMER_SECRET_KEY. '%26'. $oauth_token_secret;
        $url .= '&oauth_signature_method=PLAINTEXT';
        $url .= '&oauth_timestamp='. time();
        $url .= '&oauth_token='. urlencode($oauth_access_token);
        $url .= '&oauth_version=1.0';    
        $url .= '&sid='. $session_id;
        $url .= '&fields=%2Bpresence';
        $url .= '&fields=%2Bgroups';
        $url .= '&fields=%2Baddressbook';
        //additional header
        $header[] = 'Content-type: application/json; charset=utf-8';
        $rs = curl($url, 'get', $header);
        if (stripos($rs, 'contact') === false) return false;
        
        $js = json_decode($rs, true);
        print_r(json_encode($js['contacts']));

    }


    function curl($url, $method = 'get', $header = null, $postdata = null, $includeheader=FALSE, $timeout = 60)
    {
        $s = curl_init();
        curl_setopt($s,CURLOPT_URL, $url);
        if ($header) 
    curl_setopt($s,CURLOPT_HTTPHEADER, $header);
        /*if ($this->debug)*/
        curl_setopt($s,CURLOPT_VERBOSE, FALSE);
        curl_setopt($s,CURLOPT_TIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_MAXREDIRS, 3);
        curl_setopt($s,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($s,CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($s,CURLOPT_COOKIEJAR, 'cookie.txt');
        curl_setopt($s,CURLOPT_COOKIEFILE, 'cookie.txt'); 
        if(strtolower($method) == 'post')
        {
    curl_setopt($s,CURLOPT_POST, true);
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        else if(strtolower($method) == 'delete')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'DELETE');
        }
        else if(strtolower($method) == 'put')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        curl_setopt($s,CURLOPT_HEADER, $includeheader);  
        //curl_setopt($s,CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');
        curl_setopt($s, CURLOPT_SSL_VERIFYPEER, false);

        $html    = curl_exec($s);
        $status = curl_getinfo($s, CURLINFO_HTTP_CODE);

        curl_close($s);
        return $html;
    }




    0
  • Just provide these three parameter to function and these will print all yahoo contacts for you..

    function contactlist()
    {
            $oauth_access_token = ' ';
        $oauth_token_secret = ' ' ;
        $session_id     = ' ' ;
        //prepare url
        $url = 'http://developer.messenger.yahooapis.com/v1/contacts';
        $url .= '?oauth_consumer_key='. CONSUMER_KEY;
        $url .= '&oauth_nonce='. uniqid(rand());
        $url .= '&oauth_signature='. CONSUMER_SECRET_KEY. '%26'. $oauth_token_secret;
        $url .= '&oauth_signature_method=PLAINTEXT';
        $url .= '&oauth_timestamp='. time();
        $url .= '&oauth_token='. urlencode($oauth_access_token);
        $url .= '&oauth_version=1.0';    
        $url .= '&sid='. $session_id;
        $url .= '&fields=%2Bpresence';
        $url .= '&fields=%2Bgroups';
        $url .= '&fields=%2Baddressbook';
        //additional header
        $header[] = 'Content-type: application/json; charset=utf-8';
        $rs = curl($url, 'get', $header);
        if (stripos($rs, 'contact') === false) return false;
        
        $js = json_decode($rs, true);
        print_r(json_encode($js['contacts']));

    }


    function curl($url, $method = 'get', $header = null, $postdata = null, $includeheader=FALSE, $timeout = 60)
    {
        $s = curl_init();
        curl_setopt($s,CURLOPT_URL, $url);
        if ($header) 
    curl_setopt($s,CURLOPT_HTTPHEADER, $header);
        /*if ($this->debug)*/
        curl_setopt($s,CURLOPT_VERBOSE, FALSE);
        curl_setopt($s,CURLOPT_TIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_MAXREDIRS, 3);
        curl_setopt($s,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($s,CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($s,CURLOPT_COOKIEJAR, 'cookie.txt');
        curl_setopt($s,CURLOPT_COOKIEFILE, 'cookie.txt'); 
        if(strtolower($method) == 'post')
        {
    curl_setopt($s,CURLOPT_POST, true);
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        else if(strtolower($method) == 'delete')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'DELETE');
        }
        else if(strtolower($method) == 'put')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        curl_setopt($s,CURLOPT_HEADER, $includeheader);  
        //curl_setopt($s,CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');
        curl_setopt($s, CURLOPT_SSL_VERIFYPEER, false);

        $html    = curl_exec($s);
        $status = curl_getinfo($s, CURLINFO_HTTP_CODE);

        curl_close($s);
        return $html;
    }




    0
  • Hi ,
    Please give the detail that how i can get these three parameters and use this fuction

    Thanks.
    0
  • HI please tell me where to get those three parameters....


    QUOTE(Viscus @ 24 Jul 2012 9:33 PM)
    Just provide these three parameter to function and these will print all yahoo contacts for you..

    function contactlist()
    {
            $oauth_access_token = ' ';
        $oauth_token_secret = ' ' ;
        $session_id     = ' ' ;
        //prepare url
        $url = 'http://developer.messenger.yahooapis.com/v1/contacts';
        $url .= '?oauth_consumer_key='. CONSUMER_KEY;
        $url .= '&oauth_nonce='. uniqid(rand());
        $url .= '&oauth_signature='. CONSUMER_SECRET_KEY. '%26'. $oauth_token_secret;
        $url .= '&oauth_signature_method=PLAINTEXT';
        $url .= '&oauth_timestamp='. time();
        $url .= '&oauth_token='. urlencode($oauth_access_token);
        $url .= '&oauth_version=1.0';    
        $url .= '&sid='. $session_id;
        $url .= '&fields=%2Bpresence';
        $url .= '&fields=%2Bgroups';
        $url .= '&fields=%2Baddressbook';
        //additional header
        $header[] = 'Content-type: application/json; charset=utf-8';
        $rs = curl($url, 'get', $header);
        if (stripos($rs, 'contact') === false) return false;
        
        $js = json_decode($rs, true);
        print_r(json_encode($js['contacts']));

    }


    function curl($url, $method = 'get', $header = null, $postdata = null, $includeheader=FALSE, $timeout = 60)
    {
        $s = curl_init();
        curl_setopt($s,CURLOPT_URL, $url);
        if ($header) 
    curl_setopt($s,CURLOPT_HTTPHEADER, $header);
        /*if ($this->debug)*/
        curl_setopt($s,CURLOPT_VERBOSE, FALSE);
        curl_setopt($s,CURLOPT_TIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($s,CURLOPT_MAXREDIRS, 3);
        curl_setopt($s,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($s,CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($s,CURLOPT_COOKIEJAR, 'cookie.txt');
        curl_setopt($s,CURLOPT_COOKIEFILE, 'cookie.txt'); 
        if(strtolower($method) == 'post')
        {
    curl_setopt($s,CURLOPT_POST, true);
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        else if(strtolower($method) == 'delete')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'DELETE');
        }
        else if(strtolower($method) == 'put')
        {
    curl_setopt($s,CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($s,CURLOPT_POSTFIELDS, $postdata);
        }
        curl_setopt($s,CURLOPT_HEADER, $includeheader);  
        //curl_setopt($s,CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');
        curl_setopt($s, CURLOPT_SSL_VERIFYPEER, false);

        $html    = curl_exec($s);
        $status = curl_getinfo($s, CURLINFO_HTTP_CODE);

        curl_close($s);
        return $html;
    }




    0
  • When Creating new project youll get that parameters...

    -3
  • i want import webmail contacts to my website.. Is it possible..?

    0
  • Please help me..

    0
  • Hi Karthikeyan, Can you send me the zend code plz on anand@techaheadcorp.com

    Thanks a lot!

    0
  • Hi Karthikeyan, Can you send me the zend code plz on anand@techaheadcorp.com

    Thanks a lot!

    1
  • The parameters $oauth_access_token $oauth_token_secret $session_id

    are not in the project details.

    Project details has only Consumer Key: Consumer Secret: Application URL: App Domain

    In order to get parameters it's needed to create a request

    However when I run https://api.login.yahoo.com/oauth/v2/ get_request_token?oauth_nonce=ce2130523f788f313f76314ed3965ea6 &oauth_timestamp=1202956957 &oauth_consumer_key=123456891011121314151617181920 &oauth_signature_method=plaintext &oauth_signature=abcdef &oauth_version=1.0 &xoauth_lang_pref="en-us" &oauth_callback="http://yoursite.com/callback"

    I get no answers from the url oauth_problem=parameter_absent&oauth_parameters_absent=oauth_callback

    Do you have an idea what possibly is wrong?

    2
  • Hi Luri, even I am facing the same problem.. can you please help me to get the three parameters inorder to get the contacts?

    0
  • Hello Friends ....

        please give me the code for "Importing Yahoo contacts" using Javascript.....
    

    My email : naga.siva21@yahoo.com

    0

Recent Posts

in Contacts