Showing posts with label Oauth Yahoo. Show all posts
Showing posts with label Oauth Yahoo. Show all posts

Saturday, October 20, 2012

Get Yahoo contacts from address book

Mr. Antony request me how to list all email ids from user's yahoo email account. here is the simple solution to get all Emails from user contact list in yahoo address book.

In order to work with Yahoo Address book we need to create oauth Project on yahoo developer network. let us create it first.

Step: 1

Select My Projects on Top Right below the search box. (You are ask to Login with existing yahoo account)

Step: 2

 Click New Project Button

Step 3:

Select Application Type "Standard"

Step 4: ( Fill your Application as per the form below with your own values)

Step 5: (Get your Project Keys)

Application ID: below the Project Name
Consumer Key and Consumer Secret Inside the Box

Step 6: (Verify your Domain)


Step: 7 (Download Yahoo PHP SDK -  Included in Demo Download)

index.php ( Show the Button labled "Get Yahoo Contacts")
<p align="center"><br />

<a href="getContact.php" style="background:#939; color:#FFF; 
padding:10px; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; 
text-decoration:none; font-size:14px; font-style:italic; margin-top:50px; 
text-align:center;">Get Yahoo Contacts</a></p>


Get List of contacts using YQL after user access

<?php session_start();


// Replace your Own KEYS 

// Your Consumer Key (API Key) goes here.
// Your Consumer Secret goes here.
define('OAUTH_CONSUMER_SECRET', "febded04011a8e6e2f1227b9e24688f2252587a");
// Your application ID goes here.
define('OAUTH_APP_ID', "mShtC7c");
// Call back URL

    Consumer Key:
    Consumer Secret:
    Application URL:
    App Domain:


$session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);   

$user = $session->getOwner();

$query = sprintf("select * from social.contacts where guid=me;");  
$response = $session->query($query); 


   foreach($response->query->results->contact as $id){

       foreach($id->fields as $subid){

               if( $subid->type == 'email' )
               $emails[] = $subid->value;


echo "<pre>";
<br />
<br />
<a href="index.php">Back</a>

Download This Script     Live Demo     Download Script