TwitterService.java

/**
 * Copyright (c) 2013 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */

package com.nokia.example.statusshout.engine;

import javax.microedition.content.Registry;
import javax.microedition.midlet.MIDlet;

/**
 * Provides methods for authenticating to Twitter and sharing tweets.
 * 
 * Note: This is just a placeholder to demonstrate how to add new OAuth services
 * to the application.
 */
public class TwitterService extends OAuthService {
    // Constants
    private static final String CONSUMER_KEY = ""; // Twitter consumer key
    private static final String CONSUMER_SECRET = ""; // Twitter consumer secret
     

    /**
     * Constructor.
     */
    public TwitterService(MIDlet midlet, ShareListener listener) {
        super(midlet, listener);
    }

    /**
     * @see javax.microedition.content.ResponseListener#invocationResponseNotify(javax.microedition.content.Registry)
     */
    public void invocationResponseNotify(Registry registry) {
        // TODO Auto-generated method stub
    }

    /**
     * @see com.nokia.example.statusshout.engine.OAuthService#authenticate()
     */
    public void authenticate() {
        if ((CONSUMER_KEY.length() == 0 || CONSUMER_SECRET.length() == 0) && listener != null) {
            listener.onError("No Twitter key and/or secret defined!");
        }
    }

    /**
     * @see com.nokia.example.statusshout.engine.OAuthService#isValid(java.lang.String)
     */
    public boolean isValid(String token) {
        // TODO Auto-generated method stub
        return false;
    }

    /**
     * Shares image and/or message.
     * 
     * @param imageuri The URI of the image to share.
     * @param imageMimeType The mime type of the image to share.
     * @param message The message to share.
     */
    public void share(final String imageUri, final String imageMimeType, final String message) {
        if (listener != null) {
            listener.onError("Twitter support is not implemented.");
        }
    }
}