Little Description
1. If user want to login with his yahoo account he is redirected to yahoo login page from our website for authentication.
2. After successful login yahoo issues user data along with his GUID (Globally Unique Identifier) to our website.
3. We are identifying a user using his GUID in our database. In third step we need to check our database for existence of GUID if it is present the user is old user and display his account. If GUID is not present insert a new record and allot new privileges for him by creating a new account.
4. Display user account with his data.
In order to start working with Yahoo SDK you need to register a web application and get the Application ID, Consumer keys.
1. Creating a new Application
a) Register a new application
b) Get the Application ID, Consumer Key and Consumer Secret. Setup permission level to your application as much as you need.
Download Library File
1. If user want to login with his yahoo account he is redirected to yahoo login page from our website for authentication.
2. After successful login yahoo issues user data along with his GUID (Globally Unique Identifier) to our website.
3. We are identifying a user using his GUID in our database. In third step we need to check our database for existence of GUID if it is present the user is old user and display his account. If GUID is not present insert a new record and allot new privileges for him by creating a new account.
4. Display user account with his data.
In order to start working with Yahoo SDK you need to register a web application and get the Application ID, Consumer keys.
1. Creating a new Application
a) Register a new application
b) Get the Application ID, Consumer Key and Consumer Secret. Setup permission level to your application as much as you need.
<?php require 'lib/Yahoo.inc'; session_start();
/* Place Yoru Consumer Key here */
define('OAUTH_CONSUMER_KEY', 'your_consumer_key');
/* Place your Consumer Secret */
define('OAUTH_CONSUMER_SECRET', 'your_consumer_secret');
/* Place your Application Id here */
define('OAUTH_APP_ID', 'your_app_id');
/* Your return url which you provide when create application */
define("YAHOO_APPLICATION_URL", "http://allinone.com/yahoo.com");
$session = YahooSession::requireSession(
OAUTH_CONSUMER_KEY,
OAUTH_CONSUMER_SECRET,
OAUTH_APP_ID,
YAHOO_APPLICATION_URL
);
if (is_object($session)) { $user = $session->getSessionedUser(); $profile = $user->getProfile();
$status = $user->getPresence(); // Fetch the status for the current user.
$name = $profile->nickname; // Getting user name $guid = $profile->guid; // Getting Yahoo ID
$start = 0; $count = 100; $total = 0;
$connections = $user->getConnections($start, $count, $total);
$updates = $user->getUpdates(); //Fetch the updates for the current user.
//Fetch the updates for the connections of the current user.
$connectionUpdates = $user->getConnectionUpdates();
}
/* POSTING USER ACTIVITIES */
- $user = $session->getSessionedUser();
- // set the status for the user
- $status = "is hacking";
- $user->setStatus($status);
- // store the update data
- $title = "wrote a new blog post.";
- $description = "Lorem ipsum dolor sit amet...";
- $link = "http://pritomkumarb.blogspot.com/blog/my-awesome-blog-post";
- // create an unique hash of the update data using md5
- $suid = md5($title.$description.$link.time());
- // insert the update...
- $user->insertUpdate($suid, $title, $link, $description);
USING YQL
Using Yahoo! Query Language (YQL) in your applications lets you query for data across many other Yahoo! APIs and other data sources across the internet. Learn more about Yahoo! Query Language (YQL) here.
The sample query below gets the user's location and queries the GeoPlanet API in order to return structured place data.
- $query = sprintf("select * from geo.places where text='ballard';");
- $response = $session->query($query);
- print_r($response);
?>