Hope that code works because your screwed
Hope that code works because your screwed

How to fetch contacts from yahoo account

It is been a tough job now-a-days to fetch contact details from yahoo account. I was struggling for days to fetch the emails from my own yahoo account using yahoo api, then after several days finally got the success. So as i was struggling for long, may be possible there are people like me also finding it hard to get emails, so i thought of sharing the whole process here.

Simple steps to fetch contact details

1. Create a yahoo application by visiting http://developer.yahoo.com. Get application ID, its secret key and consumer key. Make sure while creating your application, you provide the correct domain name on which you will use this module.

2. Download the complete working module for this from our git repository. Create a folder named Yahoo, put the repository content in this folder, then put folder Yahoo in your root directory.

Easy so far.

3. Update your application's ID, its secret key, domain name which you specified at the time of creation of your yahoo app, and consumer key in common.inc.php file under email folder.

Done ?

4. Run http://Your_Domain/Yahoo/email/simpleauth.php in your browser.

And we are done, emails of your contacts are on your screen.
If you need complete profile, then uncomment "print_r($profile);" in file simpleauth.php. And fetch whatever you want from this array.

Hope this helped. Thanks. Any query is most welcomed.


Read more

Facebook Graph API Access Tokens

When a developer start using Facebook Graph API  first thing that comes to his mind is authentication by Facebook. Most popular word used is Facebook documentation for this is access token.

What is access token?
Why i need it?
What is its purpose?
These are the common question comes to developers mind when he/she heard about this world.

Facebook implementation of the OAuth 2.0 involves three different steps:-1. User authentication, 2. App authorization and 3. App authentication. User authentication ensures that the user is who they say they are. App authorization ensures that the user knows exactly what data and capabilities they are providing to your app. App authentication ensures that the user is giving their information to your app and not someone else. Once these steps are complete, your app is issued an user access token that you enables you to access the user's information and take actions on their behalf.

How to get access token by PHP SDK ?
$facebook = new Facebook(array(
            'appId' => APP_ID,
            'secret' => APP_SECRET,
          )); 
$facebook->getAccessToken();
How to get extend it ? PHP sdk 3.2.2 provides inbuilt method to extend access token to 60 days validity. The function name is setExtendedAccessToken, and it destroys the session afterwards, to remove the risk of having two active sessions. Also, the function no longer actually returns the token, but instead stores it within the persistant data. You can therefore get the new access token with the public function getAccessToken afterwards.  Grab the new SDK from official Facebook PHP SDK github page to make sure you're up to date. 
$facebook->setExtendedAccessToken();
$facebook->getAccessToken();
Access token Debugging
Debug online https://developers.facebook.com/tools/debug Debug by api
GET /debug_token?
     input_token={input-token}&
     access_token={access-token}

https://developers.facebook.com/docs/facebook-login/access-tokens/#debug

How to handle expired tokens


Official documentation have some good resources to explain this.
https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/

More about tokens

https://developers.facebook.com/docs/facebook-login/access-tokens/






Read more

Run FQL queries with Facebook PHP SDK

Foreword

So the other day while building a Facebook application, I needed to get some information that I just couldn’t find any way to get other than through the use of FQL .

Getting Started

So if you’re looking to run a FQL query and you’re using the new PHP SDK for the Graph API, your code should look something like this:
$facebook = new Facebook(array(
       'appId'  => 'YOUR_API_KEY',
       'secret' => 'YOUR_API_SECRET',
       'cookie' => true,
));

// get extended acces token with 60 days validity
$facebook->setExtendedAccessToken();
$accessToken = $facebook->getAccessToken();

 $fql = "Your query";

 $response = $facebook->api(array(
     'method' => 'fql.query',
     'query' =>$fql,
 ));

 print_r($response);

$param  =   array(
      'method'    => 'fql.query',
      'access_token' => $accessToken,
      'query'     => $fql,
      'callback'  => ''
);
$response   =   $facebook->api($param);
print_r($response);


Read more

Wordpress Menus – Add a register login / logout link


Foreword

While building a WordPress Application, I have to add register, login/logout link to my menu and i gone through a very nice post. But what if you have multiple menus in your theme ? I gone through this situation and want to share my code.
 
Getting Started
Create a menu without theme location and call it wherever you want in your in your theme.

and put this code in theme functions functions.php
function add_login_logout_link($items, $args) {
    if (empty($args->theme_location)) {
        if (is_user_logged_in()) {
            $newitems = '';
            $newitems .= '
  • Logout
  • '; } else { $newitems = ''; $newitems .= '
  • Register
  • '; $newitems .= '
  • Login
  • '; } return $newitems; } else { return $items; } } add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);


    Read more