title: OAuth with Android
body: <p>I am attempting to access the Yelp API. I have obtained my keys and have read about 40 articles explaining what I need to do and I have attempted everything. The key and what not are valid. I am getting the following:</p>
  
  <pre><code>05-16 17:39:54.955: E/AndroidRuntime(538): java.lang.NoClassDefFoundError: oauth.signpost.commonshttp.CommonsHttpOAuthConsumer
  </code></pre>
  
  <p>I have imported the commons-codec-1.6 jar, the signpost-commonshttp4-1.2.1.2.jar, and the signpost-core-1.2.1.2.jar.</p>
  
  <p>I am still getting the error message. Any help?</p>
  
  <pre><code>import java.net.HttpURLConnection;
  import java.net.URL;
  import java.util.HashMap;
  import java.util.Map;
  
  import oauth.signpost.OAuth;
  import oauth.signpost.OAuthConsumer;
  import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
  import oauth.signpost.exception.OAuthCommunicationException;
  import oauth.signpost.exception.OAuthExpectationFailedException;
  import oauth.signpost.exception.OAuthMessageSignerException;
  
  
  /**
   * Example for accessing the Yelp API.
   */
  public class Yelp {
    private String consumerKey = "";
    private String consumerSecret = "";
    private String token = "";
    private String tokenSecret = "";
  
    /**
     * Search with term and location.
     *
     * @param term Search term
     * @param latitude Latitude
     * @param longitude Longitude
     * @return JSON string response
     */
    public String search(String term, double latitude, double longitude) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException {
  
  
  
      try {
          OAuthConsumer myConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
          myConsumer.setTokenWithSecret(token, tokenSecret);
  
          String urlToPost = "http://api.yelp.com/v2/search";
          Map&lt;String, String&gt; myMap = new HashMap&lt;String, String&gt;();
          myMap.put(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
          myMap.put(OAuth.OAUTH_TOKEN, token);
          myMap.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
          myMap.put(OAuth.OAUTH_SIGNATURE, tokenSecret);
          myMap.put(OAuth.OAUTH_TIMESTAMP, Long.toString(System.currentTimeMillis() / 1000L));
          myMap.put(OAuth.OAUTH_NONCE, "asdf");
  
          urlToPost = OAuth.addQueryParameters(urlToPost, myMap);
  
          HttpURLConnection myCon = (HttpURLConnection) (new URL(urlToPost)).openConnection();
          myConsumer.sign(myCon);
  
          myCon.connect();
          return myCon.getResponseMessage();
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
    }
  }
  </code></pre>