Showing posts with label social. Show all posts
Showing posts with label social. Show all posts

Sunday, March 27, 2011

How to retrieve your twitter feeds in PERL

Retrieving twitter feeds is very simple and easy, you only need an HTTP request that returns format such as JSON, XML, RSS, and ATOM. This method doesn't require authentication.

Just follow the simple steps below using PERL. Hope you like it!

1. Install LWP::UserAgent in your server.

2. Initialize libraries, header and user agent.

require LWP::UserAgent;

my $lwpua = LWP::UserAgent->new;

my $uagent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ('Referer' => 'http://api.twitter.com/',
             'User-Agent' => $uagent);

3. Compose the HTTP request.

my $twuser = '<your twitter username>';
my $twurl = "http://api.twitter.com/1/statuses/user_timeline.<format>?screen_name=$twuser";

Supported Format:
  • JSON
  • XML
  • RSS
  • ATOM
URL Parameters:
  • user_id - The id of twitter account you want to retrieve.
  • screen_name - The username of twitter account you want to retrieve.
  • since_id - This will return the feeds after or more than the specified message id.
  • max_id - This will return the feeds before or less than the specified message id.
  • count - The number of tweets to be retrieve.
  • page - This will specify the page of the result to retrieve.
  • trim_user - When set to either true, t or 1, each tweet returned in a timeline will include a user object including only the status authors numerical id.
  • include_rts - When set to either true, t or 1, the timeline will contain native retweets (if they exist) in addition to the standard stream of tweets.
  • include_entities - When set to either true, t or 1, each tweet will include a node called "entities". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future.
4. Execute HTTP GET request.

my $response = $lwpua->get($twurl, @header);
my $return = $response->content;


That's it!! Please see below for the complete code using JSON format.

#!/usr/bin/perl

require LWP::UserAgent;
use JSON;

my $lwpua = LWP::UserAgent->new;

my $uagent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ('Referer' => 'http://api.twitter.com/', 'User-Agent' => $uagent);

my $twuser = '<your twitter username>';
my $twurl = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=$twuser";

my $response = $lwpua->get($twurl, @header);
my $return = $response->content;

my $json = JSON->new->allow_nonref;
my $json_text = $json->decode($return);

my @tweets = @{$json_text};

my $message;
foreach $tweet (@tweets)
{
  $message .= $tweet->{text}."\n";
}

print "$message";



1;

Resource: dev.twitter.com

Wednesday, March 16, 2011

How to checkin to foursquare via backend using PERL and PHP

Checking in to foursquare is more likely the same as posting a shout out, tweet or status in social network like facebook and twitter.

Foursquare follows authentication via OAuth and this post will teach you how to do it via back-end using PERL and PHP.

I assume you already read my post on how to Login to foursquare via back-end in PERL. You should be able to understand it first to proceed with authentication and do the check-in in users behalf.

Just follow the simple steps for your implementation.

1. You must have a Client ID and the Callback URL. If you don't have yet, create one by going to foursquare developers link - http://developer.foursquare.com/

2. To register a new consumer, click the "Manage OAuthConsumers" link or go to OAuth page - https://foursquare.com/oauth/

3. Enter your Application Name, Application Website, and Callback URL. Please take note that your Callback URL will be your Redirect URI.

4. After successful registration, Client ID and Client Secret will be generated.

5. What we need from now is the Client ID and once we have it, we can now start the coding part.

6. First thing we have to do is to login to users account via back-end. Please see post - Login to foursquare via back-end in PERL

7. After successful login, next step is to authenticate your application. To authenticate your app, you should pass a Client ID and your Callback URL that was registered from Consumer Registration.

$client_id = '<your client id>';
$redirect_uri = '<your callback url>';

$response = $lwpua->get("https://foursquare.com/oauth2/authenticate?client_id=$client_id&response_type=code&display=touch&redirect_uri=$redirect_uri", @header);

$form_data = $response->content;
$form_data =~ s/\n//g;

8. If this is the first time you authenticate your app, return page will be asking users permission to "Allow" the application to access account details and transact in users behalf. We can do this in back-end by implementing REGEX to get the NAME parameter of the value="Allow", then passed it on to authentication URL - https://foursquare.com/oauth2/authenticate.

$form_data =~ /form method="post" action="(.*?)"(.*?)input value="Allow" type="submit" name="(.*?)" class="input_button"/ig;

$form_action = $1;
$form_allow = $3;

$response = $lwpua->get("https://foursquare.com/oauth2/authenticate?$form_allow=Allow", @header);
$form_data = $response->content;

9. After allowing the application, foursquare will redirect the user to redirect URI that we set on step #7. Your callback URL or redirect URI must capture the CODE parameter and exchange it with TOKEN. This can now be done via PHP.

10. Foursquare will pass the CODE parameter via GET method on our Callback URL. Our Callback URL should be able to capture it and use it in exchange of an access token. To get an access token, we should pass the CODE parameter, Client ID, Client Secret, Callback URL, and Grant Type to the access token URL - https://foursquare.com/oauth2/access_token. Client ID, Client Secret, and Callback URL are data from the consumer registration, and the Grant Type should be equal to "authorization_code". Please take note that this is now on PHP.

$client_id = '<your client id>';
$client_secret = '<your client secret>';
$redirect_uri = '<your callback url>';
$grant_type = 'authorization_code';

$code = $_GET['code'];      
$oauthurl = "https://foursquare.com/oauth2/access_token?client_id=$client_id&client_secret=$client_secret&grant_type=$grant_type&redirect_uri=$redirect_uri&code=$code";

11. As per implementation below, I use the open stream to get the contents and convert it to JSON which will then return an object with an access token.

$url_handler = fopen("$oauthurl", 'r');
$json = json_decode(stream_get_contents($url_handler));
fclose($url_handler);

$token = $json->access_token;

13. Now that you have the Token, we are now ready to do the Foursquare Check-in. Going back to PERL, what we need to do here is to do a POST request to Foursquare API URL - https://api.foursquare.com/v2/checkins/add. venueId will be the place or location you want to check-in, shout is optional if you want your post to have a custom message, broadcast can be of public or private, and lastly the oauth_token which is the access token we get from step #12. Again, this is now in PERL.

$intVenueID = "<the venue id you want to check-in>";
$strShout = "<your shout message>";
$strToken = "<your access token>";

$response = $lwpua->post("https://api.foursquare.com/v2/checkins/add",
                      ['venueId' => $intVenueID,
                       'shout' => $strShout,
                       'oauth_token' => $strToken,
                       'broadcast' => 'public,faceboook,twitter'], @header);

print $response->content;

That's it!! Hope you were able to follow. In case you don't, you can refer to the scripts below. Good luck and enjoy!!

- Here's the PERL script, it composes of 2 sub functions: check_foursquare_login() and post_foursquare_checkin()


#!/usr/bin/perl

require LWP::UserAgent;

use strict;
use warnings;

use HTTP::Cookies;

my $lwpua = LWP::UserAgent->new;

my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ('Referer' => 'https://foursquare.com',
             'User-Agent' => $user_agent);

my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
                file => $cookie_file,
                autosave => 1,
                ignore_discard => 1);

$lwpua->cookie_jar($cookie_jar);

my $strUser = "<your foursquare username>";
my $strPass = "<your foursquare password>";
my $client_id = "15NGPG2GHI3S1UFMST01FOO0ABPXNFFTGJVTVSZS55W1UN4A";
my $redirect_uri = "http://localhost/foursquare/foursquare.php";
my $status = "testing foursquare status";

my $form_data = &check_foursquare_login($strUser, $strPass, $client_id, $redirect_uri);

if ($form_data =~ /^OK\|/)
{
  my ($strTag, $intUserID, $strToken) = split /\|/, $form_data, 3;
  &post_foursquare_checkin($intUserID, $strToken, '', $status);

  unlink($cookie_file);
  print "done!";
}
else
{
  $form_data =~ /form method="post" action="(.*?)"(.*?)input value="Allow" type="submit" name="(.*?)" class="input_button"/ig;

  my $form_action = $1;
  my $form_allow = $3;

  my $response = $lwpua->get("https://foursquare.com/oauth2/authenticate?$form_allow=Allow", @header);
  $form_data = $response->content;

  if ($form_data =~ /^OK\|/)
  {
    my ($strTag, $intUserID, $strToken) = split /\|/, $form_data, 3;
    &post_foursquare_checkin($intUserID, $strToken, '', $status);

    unlink($cookie_file);
    print "done!";
  }
  else
  {
    unlink($cookie_file);
    print "error authentication!";
  }
}

sub check_foursquare_login
{
  my ($strUser, $strPass, $client_id, $redirect_uri) = @_;

  # log-in to foursquare
  my $response = $lwpua->post('https://foursquare.com/mobile/login',
                      ['username' => $strUser,
                       'password' => $strPass], @header);
  $cookie_jar->extract_cookies( $response );
  $cookie_jar->save;

  $response = $lwpua->get("https://foursquare.com/oauth2/authenticate?client_id=$client_id&response_type=code&display=wap&redirect_uri=$redirect_uri", @header);

  $form_data = $response->content;
  $form_data =~ s/\n//g;

  return $form_data;
}

sub post_foursquare_checkin
{
  my ($strUserID, $strToken, $intVenueID, $strShout) = @_;
  my ($response);

  $response = $lwpua->post("https://api.foursquare.com/v2/checkins/add",
                      ['venueId' => $intVenueID,
                       'shout' => $strShout,
                       'oauth_token' => $strToken,
                       'broadcast' => 'public,faceboook,twitter'], @header);

  return $response->content;
}



1;


- Here's the PHP script. Save this in your web server and set this as your callback URL in consumer registration.


<?

$client_id = "15NGPG2GHI3S1UFMST01FOO0ABPXNFFTGJVTVSZS55W1UN4A"; // hotshots client id
$client_secret = "NEHCL3UL0KS1QJD22NLIQ5RMR4BL4IUZIJZW25VHSJ4JPZKB";
$grant_type = "authorization_code";
$redirect_uri = "http://localhost/foursquare/foursquare.php";

$code = $_GET['code'];

if ($code) {
        // get access token
        $oauthurl = "https://foursquare.com/oauth2/access_token?client_id=$client_id&client_secret=$client_secret&grant_type=$grant_type&redirect_uri=$redirect_uri&code=$code";

        $url_handler = fopen("$oauthurl", 'r');
        $json = json_decode(stream_get_contents($url_handler));
        fclose($url_handler);

        $token = $json->access_token;
        if ($token) {
                $info_contents = `curl https://api.foursquare.com/v2/users/self?oauth_token=$token`;
                $json = json_decode($info_contents);
                $userid = $json->response->user->id;

                echo "OK|$userid|$token";
        }
}


?>

Friday, February 11, 2011

Login to twitter via backend using PERL

This is the same from the last post - Login to foursquare via backend using PERL but this time, we're doing it for twitter. Just follow the 4 simple steps below.

1. Install the libraries into your server.
  • LWP::UserAgent;
  • HTTP::Cookies;
2. Initialize the libraries UserAgent and Cookies.

my $lwpua = LWP::UserAgent->new;

my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ('Referer' => 'http://m.twitter.com',
             'User-Agent' => $user_agent);

my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
                file => $cookie_file,
                autosave => 1,
                ignore_discard => 1);

$lwpua->cookie_jar($cookie_jar);

3. Post your username and password to https://mobile.twitter.com/session and save the cookies.

my $strUser = '<your twitter username>';
my $strPass = '<your twitter password>';

# log-in to twitter
$response = $lwpua->post('https://mobile.twitter.com/session',
                            ['username' => $strUser,
                             'password' => $strPass,
                             'authenticity_token' => $auth_token], @header);

$cookie_jar->extract_cookies( $response );
$cookie_jar->save;

4. You can check if successful or not by accessing https://mobile.twitter.com via GET and print the content.

$response = $lwpua->get('https://mobile.twitter.com', @header);
$form_data = $response->content;

print "$form_data\n\ndone!";


That's it! Please see the complete code below.

#!/usr/bin/perl

require LWP::UserAgent;

use strict;
use warnings;

use HTTP::Cookies;

my $lwpua = LWP::UserAgent->new;

my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ('Referer' => 'http://m.twitter.com',
             'User-Agent' => $user_agent);

my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
                file => $cookie_file,
                autosave => 1,
                ignore_discard => 1);

$lwpua->cookie_jar($cookie_jar);

# getting authenticity token
my $response = $lwpua->get('https://mobile.twitter.com/session/new', @header);
my $form_data = $response->content;

$form_data =~ s/\n//g;
$form_data =~ /input name="authenticity_token" type="hidden" value="(.*?)"/ig;

my $auth_token = $1;

my $strUser = '<your twitter username>';
my $strPass = '<your twitter password>';

# log-in to twitter
$response = $lwpua->post('https://mobile.twitter.com/session',
                            ['username' => $strUser,
                             'password' => $strPass,
                             'authenticity_token' => $auth_token], @header);

$cookie_jar->extract_cookies( $response );
$cookie_jar->save;

$response = $lwpua->get('https://mobile.twitter.com', @header);
$form_data = $response->content;

print "$form_data\n\ndone!";


1;


Hope you like it!! Thank you for reading.

Tuesday, January 18, 2011

How to post facebook status using OAuth with permanent TOKEN via backend in PERL and PHP

This post will teach you how to post facebook status using OAuth process via back-end. This is actually a revised version of the script I made on my previous post How to submit facebook status via back-end using PERL but instead of saving the users credentials, you just need to save the token which we get from the OAuth process.

You just need to have a web server coz facebook OAuth will require application to have a site URL as to be the callback URL in passing information. just for the sake of our testing we can use our local domain.

Just follow the simple steps below and we will be able to submit facebook status via back-end using OAuth process the "LEGAL WAY".

1. Same with my previous post, you should register your application on facebook - http://www.facebook.com/developers/createapp.php again, type in the application name and other details then once created, modify the site URL under web site tab.

2. Once you have the 3 details such as: app ID, app Secret, and site URL. we can now start coding the authorization script which will request permission for our app to do the status update.

app ID - 182635521758593
app Secret - 495625ad928ea277548d0f423f420ef0
site URL - http://localhost/facebook/

3. Since we're using PERL, you have to install the following libraries needed to run the script.
  • LWP::UserAgent;
  • HTTP::Cookies;
4. After installing the libraries, initialize UserAgent and Cookies to do HTTP request. please see below.

#!/usr/bin/perl

require LWP::UserAgent;

use strict;
use warnings;

use HTTP::Cookies;

my $lwpua = LWP::UserAgent->new;

my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ( 'Referer' => 'http://m.facebook.com/','User-Agent' => $user_agent);

my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
                file => $cookie_file,
                autosave => 1,
                ignore_discard => 1);

$lwpua->cookie_jar($cookie_jar);

5. Login to the wap site via the URL - http://m.facebook.com/login.php then save the cookies.

my $strUser = '<your facebook username/email>';
my $strPass = '<your facebook password>';
my $strStatus = '<your facebook status>';

# login to facebook
my $response = $lwpua->post('http://m.facebook.com/login.php',
                      ['email' => $strUser,
                       'pass' => $strPass,
                       'login' => 'Login'], @header);
$cookie_jar->extract_cookies( $response );
$cookie_jar->save;

6. Request for permission to post facebook status with the app ID, and site URL of your application where app ID being the "app_id" parameter and site URL being the "next" parameter. just for this testing, we can use the application "Hotshots Point Of View". the application details are stated on step no. 2.

$response = $lwpua->get('http://m.facebook.com/connect/uiserver.php?app_id=182635521758593&method=permissions.request&display=wap&next=http%3A%2F%2Flocalhost%2Ffacebook%2F&response_type=code&fbconnect=1&perms=user_photos%2Cuser_videos%2Cpublish_stream', @header);

7. Get the $response->content and parse the "form action", "post_form_id", and "fb_dtsg" via REGEX implementation below. take note that this might change as the facebook wap changes. take note as well that the $response->content might not return as expected if the user already allow the application. hence, the $response->content will be the return output of your callback or site URL. if this is the first time that the user will allow the application, expect a return page with the details we need below.

my $form_data = $response->content;

$form_data =~ s/\n//g;
$form_data =~ /form id="uiserver_form" action="(.*?)"(.*?)name="post_form_id" value="(.*?)"(.*?)name="fb_dtsg" value="(.*?)"/ig;

my $form_action = $1;
my $form_id = $3;
my $form_fbdtsg = $5;

8. Once we have the "form action", "post_form_id", and "fb_dtsg", we can now trigger user to allow our application. please see below with other details we have from step no. 2, then clear the cookies by unlink() function.

$response = $lwpua->post('http://m.facebook.com/connect/uiserver.php',
                           ['fb_dtsg' => $form_fbdtsg,
                            'post_form_id' => $form_id,
                            'app_id' => '182635521758593',
                            'display' => 'wap',
                            'redirect_uri' => 'http://localhost/facebook/',
                            'response_type' => 'code',
                            'fbconnect' => '1',
                            'perms' => 'user_photos,user_videos,publish_stream',
                            'from_post' => '1',
                            '__uiserv_method' => 'permissions.request',
                            'grant_clicked' => 'Allow'], @header);

$form_data = $response->content;
unlink($cookie_file);

9. Okay, we are just halfway there.. now that we are able to allow the app to update facebook status, next step will be the script to post facebook status, but before that, here is the complete code of the PERL script as detailed on the steps above.

#!/usr/bin/perl

require LWP::UserAgent;

use strict;
use warnings;

use HTTP::Cookies;

my $lwpua = LWP::UserAgent->new;

my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ( 'Referer' => 'http://m.facebook.com/','User-Agent' => $user_agent);

my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
                file => $cookie_file,
                autosave => 1,
                ignore_discard => 1);

$lwpua->cookie_jar($cookie_jar);

my $strUser = '<your facebook username/email>';
my $strPass = '<your facebook password>';

# login to facebook
my $response = $lwpua->post('http://m.facebook.com/login.php',
                      ['email' => $strUser,
                       'pass' => $strPass,
                       'login' => 'Login'], @header);
$cookie_jar->extract_cookies( $response );
$cookie_jar->save;

$response = $lwpua->get('http://m.facebook.com/connect/uiserver.php?app_id=182635521758593&method=permissions.request&display=wap&next=http%3A%2F%2Flocalhost%2Ffacebook%2F&response_type=code&fbconnect=1&perms=user_photos%2Cuser_videos%2Cpublish_stream', @header);

my $form_data = $response->content;

$form_data =~ s/\n//g;
$form_data =~ /form id="uiserver_form" action="(.*?)"(.*?)name="post_form_id" value="(.*?)"(.*?)name="fb_dtsg" value="(.*?)"/ig;

my $form_action = $1;
my $form_id = $3;
my $form_fbdtsg = $5;

$response = $lwpua->post('http://m.facebook.com/connect/uiserver.php',
                           ['fb_dtsg' => $form_fbdtsg,
                            'post_form_id' => $form_id,
                            'app_id' => '182635521758593',
                            'display' => 'wap',
                            'redirect_uri' => 'http://localhost/facebook/',
                            'response_type' => 'code',
                            'fbconnect' => '1',
                            'perms' => 'user_photos,user_videos,publish_stream',
                            'from_post' => '1',
                            '__uiserv_method' => 'permissions.request',
                            'grant_clicked' => 'Allow'], @header);

$form_data = $response->content;
unlink($cookie_file);



1;

10. Succeeding steps will then teach you how to submit facebook status in PHP which was triggered by facebook upon allowing our application. if you notice on our authorize URL on step no. 6, we set the "next" parameter to be the same as the value of our facebook app site URL. the "next" parameter will be used by facebook to return the CODE which we can exchange for a TOKEN that we will be using to post facebook status. please see below authorize URL from step no. 6.

http://m.facebook.com/connect/uiserver.php?app_id=182635521758593&method=permissions.request&display=wap&next=http%3A%2F%2Flocalhost%2Ffacebook%2F&response_type=code&fbconnect=1&perms=user_photos%2Cuser_videos%2Cpublish_stream

11. In back-end, the URL below was executed by our PERL script but if this link was clicked by the user, the user will be redirected to the page where in our facebook application is requesting for permission to post facebook status on users profile. if the user will allow it, facebook will then redirect it to the "next" parameter we specify on the URL above. please see facebook redirection URL format below.

http://localhost/facebook/?code=...

12. Your index page should be able to capture the CODE parameter returned by facebook and exchange it with TOKEN on the access token URL below then parse the return data to get the TOKEN. again, app ID will be the "client_id" parameter, site URL will the "redirect_uri" parameter, and the app Secret will be the "client_secret" parameter.

$code = $_GET['code'];
$oauthurl = "https://graph.facebook.com/oauth/access_token?client_id=182635521758593&redirect_uri=http://localhost/facebook/&client_secret=495625ad928ea277548d0f423f420ef0&code=$code";

$url_handler = fopen("$oauthurl", 'r');
$url_contents = stream_get_contents($url_handler);
fclose($url_handler);

$ret = explode("&", $url_contents);
$token = preg_replace('/^access_token=/', '', $ret[0]);

13. Once you have the TOKEN, you will now be able to post facebook status using CURL. please see below implementation.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
curl_setopt($ch, CURLOPT_POSTFIELDS,'access_token='.urlencode($token).'&message='.urlencode($status));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_REFERER, "http://m.facebook.com");
$page = curl_exec($ch);

14. Please take note that the TOKEN you just pulled from facebook is NOT yet permanent. Hence, you need to call another access token with the parameter grant_type=client_credentials.

$oauthurl = "https://graph.facebook.com/oauth/access_token?client_id=182635521758593&client_secret=495625ad928ea277548d0f423f420ef0&grant_type=client_credentials";

$url_handler = fopen("$oauthurl", 'r');
$url_contents = stream_get_contents($url_handler);
fclose($url_handler);

$ret = explode("&", $url_contents);
$token = preg_replace('/^access_token=/', '', $ret[0]);

15. Please see below for the complete PHP script.

<?

$status = "damn!! i'm good!! i was able to crack facebook oauth process via backend using perl and php! - http://paulgonzaga.blogspot.com";

$code = $_GET['code'];

if ($code) {
        // get access token
        $oauthurl = "https://graph.facebook.com/oauth/access_token?client_id=182635521758593&redirect_uri=http://localhost/facebook/&client_secret=495625ad928ea277548d0f423f420ef0&code=$code";

        $url_handler = fopen("$oauthurl", 'r');
        $url_contents = stream_get_contents($url_handler);
        fclose($url_handler);

        $ret = explode("&", $url_contents);
        $token = preg_replace('/^access_token=/', '', $ret[0]);

        if ($token) {
                // get user info
                $infourl = "https://graph.facebook.com/me?access_token=$token";
                $url_handler = fopen("$infourl", 'r');
                $return = json_decode(stream_get_contents($url_handler));
                fclose($url_handler);

                $userid = $return->id;
                $name = $return->name;
                $fname = $return->first_name;
                $mname = $return->middle_name;
                $lname = $return->last_name;
               
                $oauthurl = "https://graph.facebook.com/oauth/access_token?client_id=182635521758593&client_secret=495625ad928ea277548d0f423f420ef0&grant_type=client_credentials";

                $url_handler = fopen("$oauthurl", 'r');
                $url_contents = stream_get_contents($url_handler);
                fclose($url_handler);

                $ret = explode("&", $url_contents);
                $token = preg_replace('/^access_token=/', '', $ret[0]);

                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/$userid/feed');
                curl_setopt($ch, CURLOPT_POSTFIELDS,'access_token='.urlencode($token).'&message='.urlencode($status));
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
                curl_setopt($ch, CURLOPT_REFERER, "http://m.facebook.com");
                $page = curl_exec($ch);
        }
}

?>

Save the USERID and TOKEN for succeeding facebook status. Hope you like it!! Enjoy!! yeah men!! - http://paulgonzaga.blogspot.com

Sunday, January 16, 2011

The TOP 15 most important social networking sites.

The following list are the most important social networking sites as of today. The list are not based on the popularity of the sites nor how old the website is running. This is based on its importance to people's lives, self improvement, business, friendship, and how we live our lives.

  • Facebook - Initially intended for college students, then branched out by invite, and continuously growing with over 500 million members.
  • Twitter - A free social networking service that allows users to send "updates" (text-based posts that are up to 140 characters long) via SMS, instant messaging, email, the Twitter website, or an application such as Twitterrific. The site has become very popular in only a few months with over 75 million members.
  • MySpace - Over 130 million members. this site is massive, boasting the largest membership of any social networking site on the internet.
  • Linkedin - Over 75 million members. a powerful for business networking. mainly used by businessmen and organizations.
  • Foursquare - Foursquare is a social networking site build by Google that shares your global location by checking in, sending shout out, and even promote the location by leaving tips.
  • Friendster - It was considered the top online social networking service until it was overtaken by MySpace at around April 2004. Demographic studies shows that users are between 17 to 30 years of age and over 90 million members.
  • StumbleUpon - Boasting over 13 million users, StumbleUpon is a web browser plugin that allows its users to discover and rate web pages, photos, videos, and news article. We usually see this plugin on social bookmarking tools like addThis, shareThis, etc.. A great way to promote websites. It was bought by eBay for $75 million in May 2007.
  • Delicious - The website delicious which is formerly known as "del.icio.us" is a social bookmarking web service for storing, sharing, and discovering web bookmarks. The site was founded by Joshua Schachter in late 2003, and is now part of Yahoo!
  • Digg - Digg is a website made for people to share and discover content on the internet by submitting links and stories, then people votes and comments on submitted contents in a social and democratic spirit.
  • Orkut - Orkut is an Internet social networking service run by Google and named after its creator, Google employee Orkut Büyükkökten. It claims to be designed to help users meet new friends and maintain existing relationships. Now has a membership of 100 million.
  • Classmates - Over 50 million members. One of the oldest social networking sites around, Classmates was kicked off in 1995, and has proven to be a great way for members to to connect with old friends and acquaintances from throughout their lives.
  • Meetup - Over 2 million members. Meetup.com is an online social networking portal that facilitates offline group meetings in various localities around the world. Meetup allows members to find and join groups unified by a common interest, such as politics, books, games, movies, health, pets, careers or hobbies.
  • Yahoo! Pulse - Formerly known as Yahoo! 360° (a.k.a Yahoo! Days) is a personal communication portal similar to Orkut and MySpace -- it is now launched for public used already. It integrates features of social networking, blogging and photo sharing sites.
  • Xanga - Over 27 million members. Xanga the blogging community is a free Web-based service that hosts weblogs, photoblogs, videoblogs, audioblogs, and social networking profiles.
  • Care2 - Over 14 million members. Care2 is a social networking website that was founded to help connect activists from around the world.
In all, there are over 100 social networking sites on the Internet. Some of the other social networking sites that I have not included in the list above are:

Ryze, Bebo, BlackPlanet.com, Flickr.com, Reunion.com, aSmallWorld, Bebo, BlackPlanet.com, Blue Dot, Bolt, Broadcaster.com, Buzznet, CarDomain, Consumating, Couchsurfing, Cyworld, Dandelife, DeadJournal, DontStayIn, Doostang, Ecademy, eSPIN, Faceparty, Flirtomatic, Fotki, Friends Reunited, Gaia Online, Geni.com, GoPets, Graduates.com, Grono.net, Hyves, imeem, Infield Parking, IRC-Galleria, iWiW, Joga, Bonito, Last.fm, LibraryThing, LiveJournal, LunarStorm, MEETin, MiGente.com, Mixi, MOG, Multiply, My Opera Community, myYearbook, Netlog, Nexopia, OUTeverywhere, Passado, Piczo, Playahead, ProfileHeaven, Pownce, RateItAll, Searchles, Sconex, Shelfari, Soundpedia, Sportsvite, Studivz, TagWorld, TakingITGlobal, The Doll Palace, The Student Center, Threadless, TravBuddy.com, Travellerspoint, Tribe.net, Vampire Freaks, Vox, WAYN, WebBiographies, Windows Live Spaces, Woophy, XING, Xuqa, Yelp, Zaadz, Zooomr

Wednesday, December 22, 2010

The best social bookmarking widget now a days..

Social bookmarking widgets have really helped reduce clutter on web pages.

Not long ago, it was not uncommon to find bloggers putting a dozen different icons under their blog posts hoping that people would click these buttons to spread their content on the web. But as the number of social sites grew on the Internet, these numerous buttons were replaced with all-in-one widgets that not only offered more features but were easy to maintain as well.

share icon The idea is that instead of confusing your site visitors with icons of 16 different social bookmarking sites, you show them a single Share icon and they can choose the social service they want to use to save, share or bookmark your content.

Which Social Bookmarking & Sharing widget is right for your site?

The three most popular social bookmarking and sharing widgets on Internet are from Share This, Add This and Add to Any. Another service that’s relatively new but worth a mention is Tell a Friend.

Before we actually compare the features of these services, take a look at the graphic above to get some idea about the appearance of these widgets. Or you may visit this dummy page and try out any of these social sharing services.
AddThis.com

AddThis gives you complete control over the appearance and layout of the widget. You can arrange the icons in a single vertical column or put them in a horizontal strip or, if you are comfortable with CSS, you can even go for more complex hover animations.

In addition to sharing your web pages on social networks, your site visitors can also use the AddThis widget to print content or for adding the page to their browser bookmarks.

AddThis provides several analytics reports so you know what content is getting shared and what social services are most popular among your visitors. And there’s an option to add your brand name to the widget as well.

Almost every US government website (include the Whitehouse blog) uses AddThis for social sharing.
ShareThis.com

One of the unique points about the ShareThis widget is that remembers what you share. That means if you vote for a story on Digg or share a link on Twitter or stumble some page, the service will auto-save a log of all this activity into your ShareThis account. The sharing widget is available as a bookmarklet as well and this is handy for browsers like Google Chrome that don’t support add-ons.

On the publisher side, ShareThis is the only service that will allow you site visitors to share content through SMS text messages in addition to email and AIM. Though the default look of the ShareThis widget cannot be changed, you can choose which social services should be available inside the widget and their display order.

Like AddThis, ShareThis too provides detailed analytics so you can find out what people are sharing and how.
AddToAny.com

There are at least 50 different social networks and bookmarking websites on the Internet so how do you decide services that should be included in the sharing widget on your website? For instance, delicious is the most popular bookmarking service but some of your visitors could also be using Diigo or Mister-Wong so what do you do in this case? Show them both or toss a coin and pick one?

Well, the AddToAny button provides an excellent solution to this very problem. The service automatically detects social services that your visitors use and places them first in the widget. The detection mechanism is pretty good and I guess it does this by reading the browser history of visitors.

Another advantage of AddToAny is that it automatically uses your Google Analytics account for reporting. That means if you have the Google Analytics code on a page that also uses the Add To Any widget, the sharing statistics of that page will be collected just like your other Analytics data.

The layout of the Add To Any widget isn’t customizable though advanced users can hide individual tabs or even change the color scheme using CSS hacks.
Tell-A-Friend.com

With Tell-a-Friend, your site visitors can share your content with their IM buddies on Google Talk, Yahoo! Messenger, AOL and MSN/Windows Live Messenger. You can rearrange the tab order in the widget and also choose which social services should be part of the individual tabs. The service also offers a paid option incase you like to brand the widget and email message with a custom logo.

For some reason, the TAF widget on the dummy page isn’t working in IE 8 or Firefox 3.5 but I used the one on NDTV.com and their email sharing feature is pretty impressive.

Conclusion:

All the services discussed above have something unique to offer. Here’s what I would suggest:

If you are looking to customize the widget heavily or plan to use your own social bookmarking icons so that the widget on your site looks a bit different from the rest, AddThis is a perfect choice.

If you want to offer readers an option to share content via text messages or need a widget that is extremely easy to setup and also looks elegant, go with ShareThis.

The Add To Any widget is again a good choice because site visitors get to see the service they frequently use right on top but the email sharing feature in this widget will open in another window.

Tell-A-Friend is the only service that offers sharing via popular instant messaging clients, the widget also includes a rich HTML email client so visitors can add notes to their shares but the free version of TAF doesn’t offer analytics and the widget UI can be a bit confusing for new users.

http://www.labnol.org/internet/sharing-widgets-for-websites/9249/

Leadership 101


  • Leadership demands sacrifices for the near-term to receive lasting benefits. the longer we wait to make sacrifices, the harder they become. Successful people make important decisions early in their life, then manage those decisions the rest of their lives.
  • Growth does not happen by chance. If you want to be sure to grow, you need a plan something strategic, specific, and scheduled. it's a discipline that would need incredible determination from us.
  • Success comes by going the extra mile, working the extra hours, and investing the extra time. The same is true for us. If we want to get to excel in any segment of life, a little extra effort can help. Our efforts can go a long way if we only work a little smarter, listen a little better, push a little harder, and persevere a little longer.
  • Making a difference in your work is not about productivity; it's about people. When you focus on others and connect with them, you can work together to accomplish great things.
  • Envision a goal you'd like to reach. Make it big enough to scare you a little. Now write down a plan for moving toward it. Create mini-goals within the big goal, to set yourself up for continual progress. And include some risks, too. Set yourself up for success.
  • Leaders build margins, not image. A leader may be forced to take unpopular stands for the good of the company. Popularity isn't bad, but decisions made solely on the basis of popular opinion can be devastating. So take courage and make the right though sometimes painful choices.