Sunday 25 September 2016

TWITTER JAVA API: JAVA POST TO TWITTER (USING TWITTER4J API)


Dear All,

The following content is intended to demonstrate TWITTER INTEGRATION in a simplified way:

Step 1
Go to https://apps.twitter.com/

Step 2
Create New App.

Step 3
After creating new app, you shall receive following:
1. Consumer Key (API Key)
2. Consumer Secret (API Secret)
3. Access Token
4. Access Token Secret

Step 4
Download Twitter4j API kit from the below link:
http://twitter4j.org/archive/twitter4j-4.0.4.zip
Attach it to your library folder. See below.













Step 5
Compile the below core java code.

package twitterintegrator;

import java.util.logging.Level;
import java.util.logging.Logger;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;

/**
 *
 * @author Suneet
 */
public class TwitterIntegrator {

    /**
     * @param args the command line arguments
     */
    
    //CREATE TWITTER OBJECT USING API TOKENS
    synchronized static Twitter getTwitter() {
        Twitter twitter = TwitterFactory.getSingleton();
        
        //Keep the "Consumer Secret" a secret. 
        //This key should never be human-readable in your application.
        twitter.setOAuthConsumer("Consumer Key (API Key)", "Consumer Secret (API Secret)");
        //This access token can be used to make API requests on your own account's behalf. 
        //Do not share your access token secret with anyone.
        AccessToken at = new AccessToken("Access Token", "Access Token Secret");
        twitter.setOAuthAccessToken(at);
        //Authorized Twitter object created.
        return twitter;
    }
    
    public static void main(String[] args) {
        try {
            // TODO code application logic here
            //Create Twitter object.
            Twitter twitter = getTwitter();
            //Set status message by calling 'updateStatus()' method.
            twitter.updateStatus("Hello World! - Posted from my app.");
            //You are encouraged to explore more functions of the Twitter object.
            System.out.println("Message posted.");
        } catch (TwitterException ex) {
            Logger.getLogger(TwitterIntegrator.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Step 6
Check Status on https://twitter.com/

Sunday 24 April 2016

INTUIT JAVA API: AUTHORIZATION (JAVA TO QUICKBOOKS ONLINE INTEGRATION)

Dear All,

The following content is intended to demonstrate INTUIT API AUTHORIZATION in a simplified way:


Note: This tutorial assumes that you have already registered in https://developer.intuit.com
and created and and registered new app. So you must be having 'Oauth Consumer Key' & 'Oauth Consumer Secret'.

Outlined Steps: 

  • Get REQUEST TOKEN, REQUEST TOKEN SECRET & Authorization URL.
  • Go to Authorization URL select the company to be authorised and click Authorize button.
  • Get OAUTH VERIFIER CODE post authorization (after autorization button is clicked) through a GET request from Intuit API server.
  • Get ACCESS TOKEN and ACCESS TOKEN SECRET using
    OAUTH VERIFIER CODE,
    REQUEST TOKEN & REQUEST TOKEN SECRET.
  • Create DateService object using 'Oauth Consumer Key', 'Oauth Consumer Secret', ACCESS TOKEN, ACCESS TOKEN SECRET & Company id (a.k.a Realm id).

CLICK HERE FOR BASIC SAMPLE CODES