Update From Facebook.com

1

Category:

spamming my own fb account..

Demo test

0

Category:

new test

Update From Twitter.com

1

Category:

test

Update From Twitter.com

1

Category:

test2

Blogger Profile Update

0

Category:

Here is the code for blogger profile update. The code is written using Apache HttpClient. Authorization to Blogger is obtained using ClientLogin method of Google Data API.


import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import com.google.gdata.client.GoogleAuthTokenFactory;
import com.google.gdata.util.AuthenticationException;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.apache.http.HttpEntity;

public class BloggerProfiler {

public static void main(String[] args) throws Exception {

String username = "synchrona.group@gmail.com";
String password = "xxxxxx";
String serviceName = "blogger";

GoogleAuthTokenFactory factory = new GoogleAuthTokenFactory(serviceName, "", null);
// Obtain authentication token from Google Accounts
String token = factory.getAuthToken(username, password, null, null, serviceName, "");
//System.out.println(token);

String serviceUrl = "http://www.blogger.com/home";
String loginUrl = "https://www.blogger.com/start?continue=" +
URLEncoder.encode(serviceUrl, "UTF-8") + "&auth=" + token;

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpgetHome = new HttpGet(loginUrl);
HttpResponse response = httpclient.execute(httpgetHome);

HttpEntity entity = response.getEntity();
//System.out.println("Status: " + response.getStatusLine());
if (entity != null) {
//System.out.println("Blogger profile page: "+EntityUtils.toString(entity));
entity.consumeContent();
}

String securityToken ="";
String security_token ="";
String USIradio = "";
String USIerror = "";

HttpGet httpgetEdit = new HttpGet("http://www.blogger.com/edit-profile.g");
response = httpclient.execute(httpgetEdit);
entity = response.getEntity();
System.out.println("Status: " + response.getStatusLine());
if (entity != null) {
String editPage = EntityUtils.toString(entity);
String[] array = editPage.split("securityToken\" type=\"hidden\" value=\"");
array = array[1].split("\">");
securityToken = array[0];
array = editPage.split("security_token\" value=\"");
array = array[1].split("\">");
security_token = array[0];
array = editPage.split("id=\"USI_");
array = array[1].split("_asynchronous");
String USI = array[0];
USIradio = "USI_"+USI+"_imgSrcRadio";
USIerror = "USI_"+USI+"_imgUrlTextError";
//System.out.println("1:"+securityToken);
//System.out.println("2:"+security_token);
//System.out.println("3:"+USI);
entity.consumeContent();
}

//update profile
HttpPost httpostProfile = new HttpPost("http://www.blogger.com/edit-profile.do");
List nvps = new ArrayList ();
nvps.add(new BasicNameValuePair("securityToken",securityToken));
nvps.add(new BasicNameValuePair("security_token" ,security_token));
nvps.add(new BasicNameValuePair("enable","true"));
nvps.add(new BasicNameValuePair("showName" ,"true"));
nvps.add(new BasicNameValuePair("showEmail","true"));
//nvps.add(new BasicNameValuePair("showFollowed","true"));//check
nvps.add(new BasicNameValuePair("email" ,"synchrona.group@gmail.com"));
nvps.add(new BasicNameValuePair("widget.displayname","Synchrona"));
nvps.add(new BasicNameValuePair("firstname" ,"Eureka" ));
nvps.add(new BasicNameValuePair("lastname" ,"" ));

nvps.add(new BasicNameValuePair("photourl" ,""));
nvps.add(new BasicNameValuePair("photowidth" ,""));
nvps.add(new BasicNameValuePair("photoheight" ,""));
//nvps.add(new BasicNameValuePair("USI_1pqgkpdqj4c5y_imgSrcRadio" ,"on"));
nvps.add(new BasicNameValuePair("imageFileName" ,""));
nvps.add(new BasicNameValuePair(USIradio ,"on"));
nvps.add(new BasicNameValuePair(USIerror ,""));

nvps.add(new BasicNameValuePair("audioclipurl" ,""));
nvps.add(new BasicNameValuePair("gender" ,"FEMALE" ));
//
nvps.add(new BasicNameValuePair("birthmonth" ,""));
nvps.add(new BasicNameValuePair("birthday" ,""));
nvps.add(new BasicNameValuePair("birthyear" ,"" ));
nvps.add(new BasicNameValuePair("showAstrologicalSigns" ,"true" ));
nvps.add(new BasicNameValuePair("url" ,""));
nvps.add(new BasicNameValuePair("wishlisturl" ,"" ));
nvps.add(new BasicNameValuePair("imusername" ,"" ));
nvps.add(new BasicNameValuePair("imnetwork","_nil_"));//JABBER etc
nvps.add(new BasicNameValuePair("widget.city" ,""));
nvps.add(new BasicNameValuePair("widget.state" ,""));
nvps.add(new BasicNameValuePair("widget.country" ,"_nil_"));
nvps.add(new BasicNameValuePair("ind" ,"_nil_"));
nvps.add(new BasicNameValuePair("occupation" ,"" ));
nvps.add(new BasicNameValuePair("interests",""));
nvps.add(new BasicNameValuePair("widget.aboutme","I am a great project!:)" ));
nvps.add(new BasicNameValuePair("movies" ,"MATRIX"));
nvps.add(new BasicNameValuePair("music" ,""));
nvps.add(new BasicNameValuePair("books" ,""));
nvps.add(new BasicNameValuePair("wackyQuestion" ,""));
nvps.add(new BasicNameValuePair("wackyAnswer" ,""));
//
nvps.add(new BasicNameValuePair("submitButton" ,"Save"));

httpostProfile.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = httpclient.execute(httpostProfile);
entity = response.getEntity();
System.out.println("Profile update: " + response.getStatusLine());
if (entity != null) {
System.out.println("Profile edit page: "+EntityUtils.toString(entity));
entity.consumeContent();
}

httpclient.getConnectionManager().shutdown();


}
}

Working with SVN for Synchrona Project

2

Category:

This article explains how to work with svn for web service development activities in synchrona project.

1 . How to put newly created web service in to svn (I have done this, therefor you will encounter the problem of creating new web service using the source available in svn. this is explained in the next step)

2 . How to create new web service using a project hosted on svn

3 . how to commit changes

4 . how to checkout from hosted svn.

I am not going to explain first point here, since we already have added web service data to the svn. problem is how to get this data back and crate your own new web service. this is explained with screen shots to minimize the problems you will face.

Step 1.
Create a dynamic web project, as when you are doing this creating a new web service. you don't have to put the same name for the web service as it is on the svn , you can put any name you like :).

Now , the dynamic web project you created has a folder called src . svn also has a folder called svn. Now the problem is now to import this svn src folder into your project src folder. it is explained with screen shots here.

For the demonstration purpose, i have created a dynamic web project called "tt"(any name you wish). and now i am going to add the src folder of SynchronaService project hosted on remote svn in to the your local "tt" project.

right click on the project "tt" -->> select import --> from the popup window, select other and select svn option.















then click next button,
you will get the following window.















here you have two opetions, one is create a "new repository location" second is use "existing repository location". since you have not work with our project svn yet, you have to select the first step which is "create a new repository location". Then click next. add the following url in the next window.

https://synchrona.googlecode.com/svn/trunk/

then it will prompt you to this location.















accept it permanently.

it will prompt to this window.















here give your Google account user name for the username field. But don't give, your google account password, it should be the password given to you by google svn. you can get it from here. it is displayed in this window
















then it will prompt to this window. here you need to select src folder of project synchrona .















click next, select "check out as a project in the workspace" option

then you need to select your projects src folder location, to do that , uncheck the check box and add search your project location















hope this would work for you as mentioned

Accessing Facebook Through Java application

0

Category: , , , , , ,

This article will discuss following key points ,

Login facebook Using Apache HttpClient library and Facebook
RestAPI. Setting facebook status message using HttpClient
library and Facebook RestAPI and if possible we will discus
how to update fb profile data through java application as
well. you fist have to have following libraries with you,

commons-codec-1.4.jar
httpclient.jar
httpcore.jar
httpmime.jar

First HttpClient Instance which will be used through out the program.


--------------------------------------------------------------------------
HttpClient httpclient = new DefaultHttpClient();
--------------------------------------------------------------------------


now , if you just need to read a webpage , follow this step


--------------------------------------------------------------------------
HttpGet httpget = new HttpGet("http://www.facebook.com/login.php");
--------------------------------------------------------------------------


and then using the above created instance, execute this GET method


--------------------------------------------------------------------------
HttpResponse response = httpclient.execute(httpget);
--------------------------------------------------------------------------


next problem is how do you read the output received performing
this get request,


--------------------------------------------------------------------------
HttpEntity entity = response.getEntity();
if (entity != null) {

String responseStr = EntityUtils.toString(entity);
// System.out.println(responseStr);
}
--------------------------------------------------------------------------


That is all you need to do in order to deal with HttpClient library for retrieving webpages only.Following is a summery of above steps for retrieving Facebook Homepage


--------------------------------------------------------------------------
/*Step1 : Create httpclient instance*/

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://www.facebook.com/login.php");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
String responseStr = EntityUtils.toString(entity);
// System.out.println(responseStr);
}


<--------------------------------------------------------------------->

Next thing to be discussed is , how to make an post using HttpClient library, Lets follow the following example of login to the fb.

Fist create HttpPost instance as you created that for HttpGet call. For the example we are following, posting is done on facebook site. its as follows


--------------------------------------------------------------------------
HttpPost httpost = new HttpPost("http://www.facebook.com/login.php");
--------------------------------------------------------------------------


next step is to identify the parameters that you need to pass to perform this post request. we add all the parameters in to array list. array list contains objects of the type NameValuePair.


--------------------------------------------------------------------------
List nvps = new ArrayList();
--------------------------------------------------------------------------

next thing is to identify what are the parameters which should be passed with post request, you should have question how do I know these name value pairs to pass with the post request. this name value pairs depends on

nvps.add(new BasicNameValuePair("email", "harini.sync@gmail.com"));
nvps.add(new BasicNameValuePair("pass" , "pass1234"));
nvps.add(new BasicNameValuePair("login", ""));