public void sendPost() {
String title = posttitle.getText().toString();
String body = poststring.getText().toString();
HttpPost hpost = new HttpPost("http://api.tumblr.com/v2/blog/"
+ blogname.getText().toString() + ".tumblr.com/post?api_key="
+ token);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("type", "photo"));
nameValuePairs.add(new BasicNameValuePair("caption", "Testing"));
// nameValuePairs
// .add(new BasicNameValuePair("source",
//
URLEncoder.encode("http://www.sanatansociety.org/beeld/Paintings100/ram_ramayana.jpg")));
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// bitmap.compress(CompressFormat.JPEG, 0 , bos);
bitmap.compress(CompressFormat.JPEG, 50, bos);
byte[] bitmapdata = bos.toByteArray();
String img = URLEncoder.encode(com.example.tumblrnew.Base64
.encodeBytes(bitmapdata));
nameValuePairs.add(new BasicNameValuePair("data", Base64
.encodeToString(bitmapdata, Base64.NO_WRAP)));
try {
hpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
debug += e.toString();
}
consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
consumer.setTokenWithSecret(token, secret);
try {
consumer.sign(hpost);
} catch (OAuthMessageSignerException e) {
debug += e.toString();
} catch (OAuthExpectationFailedException e) {
debug += e.toString();
} catch (OAuthCommunicationException e) {
debug += e.toString();
}
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse resp = null;
try {
resp = client.execute(hpost);
} catch (ClientProtocolException e) {
debug += e.toString();
} catch (IOException e) {
debug += e.toString();
}
String result = null;
try {
result = EntityUtils.toString(resp.getEntity());
} catch (ParseException e) {
debug += e.toString();
} catch (IOException e) {
debug += e.toString();
}
debug += result;
debugStatus.setText(debug);
}
i had successfully login into the tumblr using oauth but when trying to
upload the image it send the error mesg photo uploading error
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
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].
For more options, visit https://groups.google.com/groups/opt_out.