Chatter API Post Update via Java

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.*;

public class ChatterIntegrate {

	 * @param args
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
	    String oauthToken = "00DA0000000ao2F!ASAAQN3kdIrLpcdqrtUBEpKBJg_TK72qTx7urEh.AflgORiF05b_JVEDR1wjBFi9Y229Sni0MhJ1xRm3SJ8KsaM7M.O3_0ic";
	    String url = "";
	    String text = "My first post to Chatter via Java";
	    Part[] parts = {
	        new StringPart("text", text),

	    final PostMethod postMethod = new PostMethod(url);
	    try {
	      postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
	      postMethod.setRequestHeader("Authorization", "OAuth " + oauthToken);
	      postMethod.addRequestHeader("X-PrettyPrint", "1");
	      HttpClient httpClient = new HttpClient();
	    } finally {


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s