Posted: March 8, 2014 in Php
Tags: , ,

Courtesy:-http://25labs.com/import-gmail-or-google-contacts-using-google-contacts-data-api-3-0-and-oauth-2-0-in-php/

First, let me introduce what Contacts Data API and OAuth is.

OAuth

OAuth (Open Authorization) is an open standard for authorization. It allows users to share their private resources (e.g. photos, videos, contact lists) stored on one site with another site without having to hand out their credentials, typically username and password.

Google Contact Data APIs

The Contacts Data API allows client applications to view and update a user’s contacts. Contacts are stored in the user’s Google Account; most Google services have access to the contact list.

You can easily find many source codes for importing Gmail contacts by Googling. But most of them use outdated Google Contact Data API or OAuth. By using the latest APIs we can easily import the contacts with fewer lines of code and is much more efficient than the old version. OAuth is in its second generation today. OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows for web applications, desktop applications, mobile phones, and living room devices. OAuth 2.0 is not backward compatible with OAuth 1.0. Using the older APIs you couldn’t retrieve the contacts in local host. That is, it was difficult to modify or edit the code for the website as the code had to be uploaded again and again to the host. But with the help of new API you can try and edit the code in local host and it works efficiently.

In this tutorial we will be using OAuth 2.0 and Google Contacts Data API.

You can refer more about them at the links below.

http://code.google.com/apis/accounts/docs/OAuth2.html

http://code.google.com/apis/contacts/

As we had a little introduction about both the APIs, we will head to the Step by Step tutorial to import the contacts.

Step 1:

Create file ‘oauth.php’ in your web-host. For the example that I have shown, I made a folder ‘oauth’ in localhost and created the file ‘oauth.php’ in the folder.

Thus, in my case, the URL for the file is http://localhost/oauth/oauth.php

Please note your URL for the file, as you will need it in the later steps.

Now paste the code below into ‘oauth.php’ and save the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
<head>
<meta name="robots" content="noindex" />
<title>Email address list - Import Gmail or Google contacts</title>
<style type="text/css">
	a:link {color:Chocolate;text-decoration: none;}
	a:hover {color:CornflowerBlue;}
	.logo{width:100%;height:110px;border:2px solid black;background-color:#666666;}
</style>
</head>
<body>
	<div >
		<a href="http://25labs.com/" >
			<img style="padding-top: 10px;" src="http://25labs.com/wp-content/themes/TheStyle/images/logo.png"></img>
		</a>
	</div>
	<br/>
	<div><b>Visit Tutorial: </b><a style="font-size:17px;" href="http://25labs.com/import-gmail-or-google-contacts-using-google-contacts-data-api-3-0-and-oauth-2-0-in-php/" >Import Gmail or Google contacts using Google Contacts Data API and OAuth 2.0 in PHP</a></div>
	<br/>
	<div style="padding-left: 50px;">
<?php
$client_id='Your Client ID goes here';
$client_secret='Your Client secret goes here';
$redirect_uri='Your Redirect URIs goes here';
$max_results = 25;

$auth_code = $_GET["code"];

function curl_file_get_contents($url)
{
 $curl = curl_init();
 $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';

 curl_setopt($curl,CURLOPT_URL,$url);	//The URL to fetch. This can also be set when initializing a session with curl_init().
 curl_setopt($curl,CURLOPT_RETURNTRANSFER,TRUE);	//TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
 curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,5);	//The number of seconds to wait while trying to connect.	

 curl_setopt($curl, CURLOPT_USERAGENT, $userAgent);	//The contents of the "User-Agent: " header to be used in a HTTP request.
 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);	//To follow any "Location: " header that the server sends as part of the HTTP header.
 curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE);	//To automatically set the Referer: field in requests where it follows a Location: redirect.
 curl_setopt($curl, CURLOPT_TIMEOUT, 10);	//The maximum number of seconds to allow cURL functions to execute.
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);	//To stop cURL from verifying the peer's certificate.

 $contents = curl_exec($curl);
 curl_close($curl);
 return $contents;
}

$fields=array(
    'code'=>  urlencode($auth_code),
    'client_id'=>  urlencode($client_id),
    'client_secret'=>  urlencode($client_secret),
    'redirect_uri'=>  urlencode($redirect_uri),
    'grant_type'=>  urlencode('authorization_code')
);
$post = '';
foreach($fields as $key=>$value) { $post .= $key.'='.$value.'&'; }
$post = rtrim($post,'&');

$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,'https://accounts.google.com/o/oauth2/token');
curl_setopt($curl,CURLOPT_POST,5);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
$result = curl_exec($curl);
curl_close($curl);

$response =  json_decode($result);
$accesstoken = $response->access_token;

$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&oauth_token='.$accesstoken;
$xmlresponse =  curl_file_get_contents($url);
if((strlen(stristr($xmlresponse,'Authorization required'))>0) && (strlen(stristr($xmlresponse,'Error '))>0)) //At times you get Authorization error from Google.
{
	echo "<h2>OOPS !! Something went wrong. Please try reloading the page.</h2>";
	exit();
}
echo "<h3>Email Addresses:</h3>";
$xml =  new SimpleXMLElement($xmlresponse);
$xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
$result = $xml->xpath('//gd:email');

foreach ($result as $title) {
  echo $title->attributes()->address . "<br>";
}
?>
	</div>
</body></html>

Step 2:

To use the Google API, you need to register your product at Google. To start the Registration process, head to Google API Console.

If you haven’t created any projects yet, then you will be seeing a page as shown below. Click ‘Create Project…’ button.

Create Project

Create Project

If you have created a project earlier, then you will be taken to an existing project directly. Click on the drop down menu that has the current project’s name which is located at the top left of the webpage (In my case it is ‘API Project’) and click ‘Create…’ in ‘Other projects’ tab. Now you will be asked to enter the name of the project. Enter a name as you wish.

API Projects drop down

API Projects drop down

API drop down - Create

API drop down – Create

Step 3:

Click ‘API Access’ from the let menu.

API Access

API Access

Step 4:

Now click on ‘Create an OAuth 2.0 client ID…’ button on the page that just opened up.

Create OAuth client ID

Create OAuth client ID

Step 5:

Fill in a name for the project. When a user clicks to retrieve the contacts, this product name will be shown on the conformation page. So please provide a sensible name.

You can optional give a product logo. The maximum allowed size for the logo is 120 x 60 pixels. This logo will also be displayed on the user’s confirmation page.

Create Client ID

Create Client ID

After you fill in the details click ‘Next’ button.

Step 6:

Now you will be taken to Client ID settings page.

Choose ‘Web application’ radio button for the Application type.

In ‘Your site or hostname’ block, choose ‘http://’ or ‘https://’ as per your requirement.

Now, enter your domain for the web application. You can also provide ‘localhost’.

Create Client ID

Create Client ID

Now, click ‘more options’ which lies next to ‘Your site or hostname’.

Enter the url that we created in Step 1 as ‘Authorized Redirect URIs’.

You will automatically have your host address as ‘Authorized JavaScript Origins’. You can enter more origins if you wish.

Create OAuth client ID

Create OAuth client ID

Click ‘Create client ID’ button.

Step 7:

Now you have registered your product and you can view the API credentials for your web application.

Note down the Client ID, Client secret and Redirect URIs. You will need them in Step 8 and 9.

API Credentials

API Credentials

Step 8:

Open oauth.php that you created in Step 1.

Replace ‘Your Client ID goes here’, ‘Your Client secret goes here’ and ‘Your Redirect URIs goes here’ with the Client ID, Client secret and Redirect URIs that you created in Step 7, respectively.

You can optionally change the number next to ‘$max_results’. It specifies the maximum number of email addresses to be retrieved.

Step 9:

Create the button or link that the user needs to click to retrieve the contact list and set its href parameter to

'https://accounts.google.com/o/oauth2/auth?client_id=your_client_id_goes_here&redirect_uri=your_redirest_urls_goes_here&scope=https://www.google.com/m8/feeds/&response_type=code'

Replace ‘your_client_id_goes_here’ and ‘your_redirest_urls_goes_here’ with the Client ID and Redirect URIs that you created in Step 7, respectively.

Or you can optionally copy the code given below, replace ‘your_client_id_goes_here’ and ‘your_redirest_urls_goes_here’ as mentioned above, and save it as a new file, may be ‘index.php’.

Then save it to your host.

Please make sure that you place this file in a directory that satisfies ‘JavaScript origins’ that you specified in Step 6.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<head>
<meta name="robots" content="noindex" />
<title>Import Gmail or Google contacts using Google Contacts Data API and OAuth 2.0</title>
<style type="text/css">
	a:link {color:Chocolate;text-decoration: none;}
	a:hover {color:CornflowerBlue;}
	.logo{width:100%;height:110px;border:2px solid black;background-color:#666666;}
</style>
</head>
<body>
	<div class="logo" >
		<a href="http://25labs.com/" >
			<img style="padding-top: 10px;" src="http://25labs.com/wp-content/themes/TheStyle/images/logo.png"></img>
		</a>
	</div>
	<br/>
	<div><b>Visit Tutorial: </b><a style="font-size:17px;" href="http://25labs.com/import-gmail-or-google-contacts-using-google-contacts-data-api-3-0-and-oauth-2-0-in-php/" >Import Gmail or Google contacts using Google Contacts Data API and OAuth 2.0 in PHP</a></div>
	<br/><br/>
	<div align="center" >
	<a  style="font-size:25px;font-weight:bold;" href="https://accounts.google.com/o/oauth2/auth?client_id=your_client_id_goes_here&redirect_uri=your_redirest_urls_goes_here&scope=https://www.google.com/m8/feeds/&response_type=code">Click here to Import Gmail Contacts</a>
	</div>
</body>
</html>

We have now successfully completed the web application to retrieve Gmail or Google contacts.

Testing the web application:

Now it’s the turn to test the application. Please follow the steps mentioned below.

Step 10:

Browse to the file that created in Step 9 using your favorite web browser. Click on the button or link that you created to retrieve the contacts.

There is a chance that you get an error similar to the one shown below, especially if you are trying it on localhost.

Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\oauth\oauth.php on line 24

If you are among the unlucky ones, please follow the procedure mentioned below to solve the issue.

Solution:

If you are on localhost open:

php/php.ini

php/browscap/php.ini (if existent)

php/php4/php.ini (if existent)

apache/bin/php.ini (if existent)

 

If you are on web host, open web host’s ‘php.ini’

 

Search for ‘extension=php_curl.dll’.

If not found add it to ‘Dynamic Extensions’ section.

If found, uncomment the statement.

Then restart Apache if on localhost.

Try Step 10 again.

Step 11:

You will be taken to a conformation page which will look similar to the one shown below.

Import Gmail Contacts

Import Gmail Contacts

Click ‘Allow Access’ button.

Step 12:

If everything went right, you will have a list of email addresses on screen.

Please comment below, if you have any queries or errors.

 

Advertisements

Courtesy:-http://www.a2zwebhelp.com/invite-friends-from-gmail

Google has introduced OAuth 2.0 and OAuth 1.0 has been officially deprecated as of April 20, 2012. So let us create a program to invite friends from Gmail using OAuth 2.0. Before you can use OAuth 2.0, you must register your application using the  Google APIs Console. First you need to create a project and follow the steps.

Create a New project:

Then Click on API Access to Create an OAuth 2.0 Client ID

Fill up the form to create your project

Setting your Client ID

Now you will get your Client ID, Client secret and Redirect URIs that we will use in our project. You can edit your Redirect URIs by clicking on Edit Setting in the right side. Once you have all info lets create our conig.php file.

config.php

In this file you have to enter Client ID, Client secret and Redirect URIs.

<?php
$clientid = 'Your Client here';
$clientsecret = 'Your Client Secret';
$redirecturi = 'http://your path/result.php'; 
$maxresults = 50; // Number of mailid you want to display.
?>


index.php

<?php include('config.php'); ?>

<a href="https://accounts.google.com/o/oauth2/auth?client_id=
<?php print $clientid;?>&redirect_uri=<?php print $redirecturi; ?>
&scope=https://www.google.com/m8/feeds/&response_type=code">
Invite Friends From Gmail</a>

 

result.php

<?php
include('config.php');
$authcode = $_GET["code"];
$fields=array(
'code'=> urlencode($authcode),
'client_id'=> urlencode($clientid),
'client_secret'=> urlencode($clientsecret),
'redirect_uri'=> urlencode($redirecturi),
'grant_type'=> urlencode('authorization_code') );

$fields_string = '';
foreach($fields as $key=>$value){ $fields_string .= $key.'='.$value.'&'; }
$fields_string = rtrim($fields_string,'&');

$ch = curl_init();//open connection
curl_setopt($ch,CURLOPT_URL,'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch,CURLOPT_POST,5);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);

$response = json_decode($result);
$accesstoken = $response->access_token;
if( $accesstoken!='')
$_SESSION['token']= $accesstoken;
$xmlresponse= file_get_contents('https://www.google.com/m8/feeds/contacts/
default/full?max-results='.$maxresults.'&oauth_token='. $_SESSION['token']);

$xml= new SimpleXMLElement($xmlresponse);
$xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
$result = $xml->xpath('//gd:email');
$count = 0;
foreach ($result as $title) {
$count++;
echo $count.". ".$title->attributes()->address . "<br><br>";
}
?>

Download all files from here

Download Project Files


Courtesy:-http://codeitall.wordpress.com/2012/01/21/yahoo-oauth-to-import-contacts/

This is similar to Gmail OAuth.

First get the API KEY from Yahoo.

Then set the application’s access on the proceding page. Like set Messanger Access Contact, then access the data for Contacts.

Get the App ID, Consumer Key, and Consumer Secret.

Then start coding the below lines.

config.php

<?php $app_id = '[Enter the Application ID]'; $consumer_key = '[Enter the Consumer Key]'; $consumer_secret= '[Enter the Consumer Secret]'; $connected_path = 'Connected.php'; $re_url = "[Enter the path to Connected.php]/Connected.php"; ?>

ReadyGetConnection.php

<?php include_once 'config.php'; ?> <a href="<?=$connected_path?>">Connect me with Yahoo</a>

Connected.php

<? include_once 'config.php'; require_once ('Yahoo.inc'); $session = YahooSession::requireSession($consumer_key,$consumer_secret,$app_id); if (is_object($session)) { $user = $session->getSessionedUser(); $profile = $user->getProfile(); $name = $profile->nickname; // Getting user name $guid = $profile->guid; // Getting Yahoo ID $contacts=$user->getContacts()->contacts; echo "Hi! ".$name."<br />"; for ($i=0,$k=0;$i<count($contacts->contact);$i++) { for($j=0;$j<count($contacts->contact[$i]->fields);$j++) { $url_data = $contacts->contact[$i]->fields[$j]->uri; $url_pie=explode("/user/", $url_data); $url_end=substr($url_pie[1], stripos($url_pie[1], "/")+1); $data=explode("/", $url_end); if ($data[2]==="email") { $email_fr[$k]=$user->getDatafrom($url_end)->email->value; $k++; } } } echo "You have ".$k." contacts.<br />"; for($i=0;$i<$k;$i++) echo ($i+1).": ".$email_fr[$i]."<br />"; } else { header("Location :".$re_url); }

Yahoo.inc can be downloaded here.


Courtesy:-http://www.idiotminds.com/get-the-contacts-list-from-yahoo-account/

 

Now a days,website s are widely using the open invite system .Here,We used Yahoo Oauth for getting the contacts list from yahoo account using Yahoo PHP SDK.Contacts are relationships that exist in Yahoo! address book, such as those entered from across the Yahoo! Network like Yahoo! Mail and Yahoo! Messenger. The API provides read and write access.
Before starting with the Yahoo PHP SDK, you will need to register a web application and you will get web-based application ID,OAuth consumer key and secret. These keys will provide you with general access to the Yahoo! Social Platform, and allow your users to authorize your application to access protected resources and information.

 

Live DemoLive Demo

Download Script

For Creating the Yahoo App,Please Click Here.

In Yahoo My projects page,Click on the New Project Button.It will appears a popup.In that popup,select the Standard option.

Yahoo Application Type

In that Popup click on Continue button after selection of the Yahoo Application type,you will get the Application form.

Yahoo Application Form

After filling the all fields,Click on the Get API Key.You will get application ID,OAuth consumer key and secret.

Yahoo Authentication Information

After that you need to set the permissions for this app.In the Permissions,You need to select the Read Public option under Social Directory (Profiles) of the Social Directory and after you need to click on Save and Change Consumer Key.

Yahoo Contacts

Here is the index.php file.In that file you need to define the OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_DOMAIN, OAUTH_APP_ID

  1. <?php
  2. // Include the YOS library.
  3. require dirname(__FILE__).’/lib/Yahoo.inc’;
  4. //for converting xml to array
  5. function XmltoArray($xml) {
  6.         $array = json_decode(json_encode($xml), TRUE);
  7.         foreach ( array_slice($array, 0) as $key => $value ) {
  8.             if ( empty($value) ) $array[$key] = NULL;
  9.             elseif ( is_array($value) ) $array[$key] = XmltoArray($value);
  10.         }
  11.         return $array;
  12.     }
  13. YahooLogger::setDebug(true);
  14. YahooLogger::setDebugDestination(‘LOG’);
  15. // use memcache to store oauth credentials via php native sessions
  16. //ini_set(‘session.save_handler’, ‘files’);
  17. //session_save_path(‘/tmp/’);
  18. session_start();
  19. // Make sure you obtain application keys before continuing by visiting:
  20. // https://developer.yahoo.com/dashboard/createKey.html
  21. define(‘OAUTH_CONSUMER_KEY’, ‘Your App Consumer Key’);
  22. define(‘OAUTH_CONSUMER_SECRET’, ‘Your App Consumer Secret’);
  23. define(‘OAUTH_DOMAIN’, ‘Your Domain’);
  24. define(‘OAUTH_APP_ID’, ‘Your App Id’);
  25. if(array_key_exists(“logout”, $_GET)) {
  26.   // if a session exists and the logout flag is detected
  27.   // clear the session tokens and reload the page.
  28.   YahooSession::clearSession();
  29.   header(“Location: index.php”);
  30. }
  31. // check for the existance of a session.
  32. // this will determine if we need to show a pop-up and fetch the auth url,
  33. // or fetch the user’s social data.
  34. $hasSession = YahooSession::hasSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
  35. if($hasSession == FALSE) {
  36.   // create the callback url,
  37.   $callback = YahooUtil::current_url().”?in_popup”;
  38. $sessionStore = new NativeSessionStore();
  39.   // pass the credentials to get an auth url.
  40.   // this URL will be used for the pop-up.
  41.   $auth_url = YahooSession::createAuthorizationUrl(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $callback, $sessionStore);
  42. }
  43. else {
  44.   // pass the credentials to initiate a session
  45.   $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
  46.   // if the in_popup flag is detected,
  47.   // the pop-up has loaded the callback_url and we can close this window.
  48.   if(array_key_exists(“in_popup”, $_GET)) {
  49.     close_popup();
  50.     exit;
  51.   }
  52.   // if a session is initialized, fetch the user’s profile information
  53.   if($session) {
  54.     // Get the currently sessioned user.
  55.     $user = $session->getSessionedUser();
  56.     // Load the profile for the current user.
  57.     $profile = $user->getProfile();
  58.     $profile_contacts=XmltoArray($user->getContactSync());
  59.    $contacts=array();
  60.    foreach($profile_contacts[‘contactsync’][‘contacts’] as $key=>$profileContact){
  61.        foreach($profileContact[‘fields’] as $contact){
  62.           $contacts[$key][$contact[‘type’]]=$contact[‘value’];
  63.        }
  64.    }
  65.   }
  66. }
  67. /**
  68.  * Helper method to close the pop-up window via javascript.
  69.  */
  70. function close_popup() {
  71. ?>
  72. <script type=”text/javascript”>
  73.   window.close();
  74. </script>
  75. <?php
  76. }
  77. ?>
  78. <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN”>
  79. <html>
  80.   <head>
  81.     <title>Get the contact list from Yahoo-Idiot Minds</title>
  82. <style type=”text/css”>
  83. body{
  84. background-color: #F2F2F2;
  85. }
  86. .yh_frnds{
  87.     list-style:none;
  88. }
  89. .yh_frnds li{
  90.     padding:10px;
  91.     float:left;
  92.     width:30%;
  93. }
  94. .frnd_list{
  95.     margin-top:-25px;
  96.     margin-left:40px;
  97. }
  98. .fb_frnds a{
  99.         text-decoration:none;
  100.          background: #333;
  101.          filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=’#333′, endColorstr=’#D95858′); /* for IE */
  102. background: -webkit-gradient(linear, left top, left bottom, from(#333), to(#D95858)); /* for webkit browsers */
  103. background: -moz-linear-gradient(top,  #333,  #D95858)/* for firefox 3.6+ */ ;
  104.     color: #FFFFFF;
  105.         float: right;
  106.         font: bold 13px arial;
  107.         margin-right:110px ;
  108. }
  109. </style>
  110.     <!– Combo-handled YUI JS files: –>
  111.     <script type=”text/javascript” src=”yahoo-dom-event.js”></script>
  112.     <script type=”text/javascript” src=”popupmanager.js”></script>
  113.   </head>
  114.   <body>
  115.     <?php
  116.       if($hasSession == FALSE) {
  117.         // if a session does not exist, output the
  118.         // login / share button linked to the auth_url.
  119.         ?>
  120.        <a href=”<?php echo $auth_url; ?>” id=”yloginLink”><img src=”yahoo-oauth-connect.png” style=”width:150px;margin-left: 350px;” title=”Get the contact list from Yahoo-Idiot Minds” alt=”Get the contact list from Yahoo-Idiot Minds” /></a>
  121.     <?php  }
  122.       else if($hasSession && $profile) {
  123.         // if a session does exist and the profile data was
  124.         // fetched without error, print out a simple usercard.
  125.        ?>
  126.       <img src=”<?php echo $profile->image->imageUrl; ?>” style=”width:10%;” />
  127.       <h2>Hi <a href=”<?php echo $profile->profileUrl; ?>” target=”_blank”><?php echo $profile->nickname; ?></a>
  128.       </h2>
  129. <?php
  130.         if($profile->status->message != “”) {
  131.           $statusDate = date(‘F j, y, g:i a’, strtotime($profile->status->lastStatusModified));
  132.           echo sprintf(“<p><strong>“</strong>%s<strong>”</strong> on %s</p>”, $profile->status->message, $statusDate);
  133.         }
  134.         echo “<p><a href=\”?logout\”>Logout</a></p>”; ?>
  135.         <ul >
  136. <?php
  137.     foreach($contacts as $user_friend){
  138.      if(isset($user_friend[’email’])){
  139. ?>
  140. <li ><img src=”yahoo1.png” width=”30″ height=”30″/>
  141. <div ><strong><?php echo $user_friend[‘name’][‘givenName’]; ?></strong><br /><?php echo $user_friend[’email’];?></div>
  142. </li>
  143. <?php }
  144.  }  ?>
  145. </ul>
  146.  <?php     }
  147.     ?>
  148.     <script type=”text/javascript”>
  149.       var Event = YAHOO.util.Event;
  150.       var _gel = function(el) {return document.getElementById(el)};
  151.       function handleDOMReady() {
  152.         if(_gel(“yloginLink”)) {
  153.           Event.addListener(“yloginLink”, “click”, handleLoginClick);
  154.         }
  155.       }
  156.       function handleLoginClick(event) {
  157.         // block the url from opening like normal
  158.         Event.preventDefault(event);
  159.         // open pop-up using the auth_url
  160.         var auth_url = _gel(“yloginLink”).href;
  161.         PopupManager.open(auth_url,600,435);
  162.       }
  163.       Event.onDOMReady(handleDOMReady);
  164.     </script>
  165.   </body>
  166. </html>

 


Courtesy:-http://wpcandy.com/made/the-sample-post-collection/

Developing a theme for public release isn’t an easy task. When you’re the only one using your theme you don’t have to worry about expanding it, but put it into the hands of other users and it better be ready for any content they throw at it. Blockquotes, lists, and floating images – there are plenty of elements that are common to blogs that need to be supported in every theme you release. Cue our new sample WordPress content.

Download our Sample WordPress Content

We put together a collection of posts, tags, categories, and pages into an XML file – perfect for importing right into a new installation of WordPress. Here are some of the things this collection includes:

  • Multiple posts with different elements in each
  • 12 Posts to force pagination
  • Blockquotes, lists – ordered and unordered – and floating images
  • Comments on a few of the posts
  • Parent, child, and grandchild categories and pages
  • Tags
  • Multiple months for the archives

Using this file is easy. Simply download the zip file and extract it. Then, log in to your WordPress admin panel and navigate to Manage>Import. Select the WordPress option from the bottom of the list, choose your file, and upload it. Within a few minutes you should have a ready-to-go development server.

Since this is the first release of this XML file, there are probably a few things we might have missed. If you think anything should be added to the collection, let us know in the comments and we’ll update it later.

Download our Sample WordPress Content


Courtesy:-http://designshack.net/articles/javascript/40-awesome-jquery-plugins-you-need-to-check-out/

The jQuery developer community has to be one of the most generous and hardworking group of people on the web. They’re constantly churning out amazingly useful and completely free tools that they share with anyone and everyone who wants to use them.

The quantity and quality of free jQuery plugins simply never ceases to amaze me. I’ve been keeping a list of some great ones that I’ve found lately and I thought I’d share it with you. Here are 40 awesome and free jQuery plugins that just about every web developer should check out.

 

Scrolling

jQuery Waypoints

Waypoints allows you to easily trigger JavaScript events at specific scroll points. Ever wonder how people build those amazing scrolling effects? This could be your answer.

screenshot

skrollr

Parallax scrolling for the masses. Skrollr helps you with all kinds of different scrolling effects including transforms, color shifts and more.

screenshot

Charts, Animations & Tables

Handsontable

A minimalistic approach to an Excel-like table editor in HTML & jQuery. The result is quite impressive, you should definitely give it a shot if you’re looking to build an interactive spreadsheet.

screenshot

jQuery Sparklines

jQuery Sparklines helps you build little inline charts that are supplied with information via HTML or JavaScript.

screenshot

Teamwork Gantt

Build incredible Gantt charts with jQuery. Seriously impressive for a free tool.

screenshot

DataTables

A jQuery plugin for creating impressive, highly functional data tables. Multi-column sorting with data type detection, smart handling of column widths and more.

screenshot

arbor.js

Build crazy looking, futuristic, animated and modular graphs. Really cool stuff.

screenshot

Layout

Wookmark jQuery Plugin

Easily build a Msonry-like layout like the one seen on Wookmark. We featured this on Design Shack here.

screenshot

jQuery Masonry

The original jQuery Masonry. Masonry arranges elements vertically, positioning each element in the next open spot in the grid.

screenshot

Isotope

An amazing layout plugin that allows for intelligent and dynamic grids of items that can be easily sorted and filtered.

screenshot

FitVids.JS

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.

screenshot

gridster.js

Gridster is a really amazing plugin that allows you to create flexible grid layouts that can be rearranged via drag and drop. You should definitely try this one.

screenshot

Freetile.js

Another plugin for masonry-style layout. It allows for any size of elements to be packed without using a fixed-size column grid, so you don’t have to worry about specifying a column width appropriate to the size of your elements.

screenshot

Text

jQuery TextExt Plugin

TextExt is a plugin for jQuery designed to provide functionality such as tag input and autocomplete. According to the developer, it was built on two main values: modularity and extensibility.

screenshot

Jeditable

Jeditable allows you to set certain HTML elements to be editable by the user. You can even set up different types of events to trigger editing capabilities: hover, click, double click, etc.

screenshot

FitText

A plugin for inflating web type. It actually makes it possible to have text that resizes with the viewport. Extremely useful for responsive web design.

screenshot

Cool UI

jQuery Knob demo

This plugin allows you to create really cool circular knobs that spin or fill up as you scroll.

screenshot

noty – A jQuery Notification Plugin

Noty is a jQuery plugin that makes it easy to create alert, success, error, warning, information and confirmation messages as an alternative the standard alert dialog. Each notification is added to a queue.

screenshot

PageSlide

This plugin helps you build a hidden, slide-in sidebar that contains pretty much anything you want it to.

screenshot

jQuery Collapse

“This plugin provides you an accessible and lightweight solution to a widely adopted interface pattern known as progressive disclosure.” That’s fancy-speak for a plugin that allows you to make content collapsable.

screenshot

Avgrund

Awesome and simple modal boxes with a really cool page animation effect.

screenshot

jQuery One Page Navigation

Smooth scrolling navigation and animation for single page sites. Super simple, incredibly handy.

screenshot

jqPagination

A great little pagination plugin. Instead of displaying a list of page numbers like traditional pagination methods, jqPagination uses an interactive ‘Page 1 of 5′ input that, when selected, allows the user to enter their desired page number.

screenshot

jQuery Joyride Feature Tour Plugin

This plugin is from ZURB, which is really all the info I need to know that it’s great. It helps you build little callouts that walk users through the features on your site one step at a time.

screenshot

Tooltips

jQuery PowerTip

A fairly robust and powerful jQuery tooltip plugin with plenty of options.

screenshot

tipsy

Another great tooltip plugin. This one is loosely based on giving you the ability to create Facebook-style tooltips.

screenshot

Slideshows, Images & Sliders

jQuery Slider Shock

A notably complete responsive jQuery / WordPress slider, with a wealth of options, settings, styles and functionality. Very well documented too!

screenshot

Backstretch

Backstretch creates dynamically-resized, slideshow-capable background images for any page or element.

screenshot

jQuery Anystretch

Anystretch is a jQuery plugin that allows you to add a dynamically-resized background image to any page or block level element. The image will stretch to fit the page/element, and will automatically resize as the window size changes.

screenshot

jQuery Lightbox

A simple lightbox based on prototype and scriptaculous.

screenshot

FlexSlider 2

FlexSlider is a responsive image slider from WooThemes with awesome features like multi-directional slide animations, semantic markup, touch support and the ability to include any HTML as a slide.

screenshot

ColorBox

Another simple lightbox plugin. Supports photos, grouping, slideshow, ajax, inline, and iframed content.

screenshot

WOW Slider

Literally one of the best, most powerful and fully featured sliders on the web. It’s responsive, has lots of different transitions and is packed with everything you could need. Go get it.

screenshot

Miscellaneous

Timeago

Quick, easy and auto-updating timestamps for jQuery. Example: About one day ago.

screenshot

jQuery Validation

The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy.

screenshot

jQuery File Upload Demo

A pretty robust file upload plugin for jQuery. Multiple file selection, drag&drop support, progress bars and preview images for jQuery.

screenshot

jQuery Instagram

Want to show an Instagram feed on your web page? With this little tool, you can.

screenshot

jQuery Shadow Plugin

Easily add all kinds of different shadows to your HTML elements. Each shadow takes very little code to implement.

screenshot

Naked Password

This one is ridiculous and potentially offensive, and a little hilarious. To encourage users to implement strong passwords, there’s a little, cartoony and non-detailed illustration (think NES) of a man or woman who gradually undresses as your password strength increases.

screenshot

MotionCAPTCHA

I hate mangled-word CAPTCHAs so much that I wrote an article about why we should kill them. This plugin provides a unique alternative that allows the user to bypass security by drawing shapes.

screenshot

jQuery Transit

Super-smooth CSS3 transformations and transitions for jQuery. Rotate, perspective, skew, scale and more.

screenshot

Sometimes when we don’t have access to modify configurations on server like in php.ini file and we still need to enable short tags for our php code. We can do it by .htaccess file. If you have not created any .htaccess file yet, create one in root directory of your website and add

php_value short_open_tag 1

That’s it for .htaccess file.

Now if you want to enable that using php.ini and if you can…

just set

short_open_tag=On

in php.ini at server and you are done.. 😀

 

Courtesy:-http://techdc.blogspot.in/2013/04/how-to-enable-php-short-tags-with.html