Hi,

I am trying to use SlideShare API for my android app. I am trying to make 
http request with parameters, and getting 

<Message ID="1">Failed API validation</Message>


I am using following code for GET request

HttpURLConnection urlConnection = null;

URL url = new URL("https://www.slideshare.net/api/2/get_slideshows_by_tag";);

urlConnection = (HttpsURLConnection) url.openConnection();

Long tsLong = System.currentTimeMillis()/1000L;

HttpClient httpClient = new DefaultHttpClient();

List<BasicNameValuePair> nameValuePairs = new LinkedList<BasicNameValuePair>();
nameValuePairs.add(new BasicNameValuePair("api_key",ClientSetup.SLIDESHARE_ID));
nameValuePairs.add(new BasicNameValuePair("ts", String.valueOf(tsLong)));
nameValuePairs.add(new 
BasicNameValuePair("hash",sha1Hash(ClientSetup.SLIDESHARE_SECRET+String.valueOf(tsLong))));
nameValuePairs.add(new BasicNameValuePair("tag", "marketing"));


HttpGet httpget = new HttpGet(url+"?"+ URLEncodedUtils.format(nameValuePairs, 
"utf-8"));
HttpResponse response = httpClient.execute(httpget);


responseBody = EntityUtils.toString(response.getEntity());
Log.d (LOG_TAG, "response body is " + responseBody);




sha1Hash function is following



String sha1Hash( String toHash )
{
    String hash = null;
    try
    {
        MessageDigest digest = MessageDigest.getInstance( "SHA-1" );
        byte[] bytes = toHash.getBytes("UTF-8");
        digest.update(bytes, 0, bytes.length);
        bytes = digest.digest();

        // This is ~55x faster than looping and String.formating()
        hash = bytesToHex( bytes );
    }
    catch( NoSuchAlgorithmException e )
    {
        e.printStackTrace();
    }
    catch( UnsupportedEncodingException e )
    {
        e.printStackTrace();
    }
    return hash;
}



Am I doing something wrong?


Thanks Grigor

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/fd8298d4-1f5d-4762-8101-59cc902e470f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to