Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: what's wrong in this program - Rest api!

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what's wrong in this program - Rest api!

    Hi , I found an error in these code when I compile it
    "uses or overrides a deprecated api"

     
    import oauth.signpost.OAuthConsumer;
    import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
     
    import org.apache.commons.io.IOUtils;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
     
     
    public class JavaRestTweet {
      static String consumerKeyStr = "####";
      static String consumerSecretStr = "####";
      static String accessTokenStr = "####";
      static String accessTokenSecretStr = "####";
     
     
      public static void main(String[] args) throws Exception {
        OAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKeyStr,
            consumerSecretStr);
        oAuthConsumer.setTokenWithSecret(accessTokenStr, accessTokenSecretStr);
     
        HttpPost httpPost = new HttpPost(
            "https://api.twitter.com/1.1/statuses/update.json?status=Back%20To%20Study.");
     
        oAuthConsumer.sign(httpPost);
     
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse httpResponse = httpClient.execute(httpPost);
     
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        System.out.println(statusCode + ':'
            + httpResponse.getStatusLine().getReasonPhrase());
        System.out.println(IOUtils.toString(httpResponse.getEntity().getContent()));
     
      }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,297
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: what's wrong in this program - Rest api!

    When a feature of a class is marked as deprecated, it means the authors have found a potential problem, have written the feature a different way and will eventually remove that feature.

    Read the API doc to see how to write the code with the recommendations.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] What's wrong with this program?
    By jtm429 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 30th, 2013, 02:28 PM
  2. Sugar CRM using Rest API in Java
    By MuhammadAwais in forum Java Theory & Questions
    Replies: 3
    Last Post: July 5th, 2013, 03:59 AM
  3. Not sure where to start: Trying to write a program dealing with an Amazon API
    By ~DrummerGirl~ in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 19th, 2013, 07:20 PM
  4. jsapi_To write a program using netbean ide for java speech api.
    By jackdoc in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 23rd, 2012, 09:38 AM
  5. Difference between Speech API and Sound API
    By zeeshanmirza in forum Java SE APIs
    Replies: 1
    Last Post: October 22nd, 2009, 01:22 AM