I am using flickrj-android-2.0.0 and following the OAuth stream. I get an access token and secret, but when I try to upload a photo to flickr, I get this error:
com.googlecode.flickrjandroid.FlickrException: 99: Not enough rights. The method requires write permissions; read .
Even I changed the write permission when I create my api key and secret, but still get the same error.
I use the code below to upload photos, please help me solve this problem, I am really stuck in this part.
public void uploadPhoto(OAuth... params)
throws ParserConfigurationException {
OAuth oauth = params[0];
OAuthToken token = oauth.getToken();
RequestContext requestContext = RequestContext.getRequestContext();
OAuth auth = new OAuth();
auth.setToken(new OAuthToken(token.getOauthToken(), token
.getOauthTokenSecret()));
requestContext.setOAuth(auth);
Uploader up = new Uploader(FlickrHelper.API_KEY, FlickrHelper.API_SEC);
UploadMetaData uploadMetaData = new UploadMetaData();
uploadMetaData.setTitle("hello world");
try {
Drawable d = getResources().getDrawable(R.drawable.icon);
Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitmapdata = stream.toByteArray();
System.out.println("Bitmap value= " + bitmapdata);
userIcon.setImageBitmap(bitmap);
up.upload("Hello From Emulator", bitmapdata, uploadMetaData);
} catch (FlickrException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
}
Thank...
source
share