I am working on an android app and want to share an image to facebook from my app but without showing dialog,I have tried as below,But its not working .Can anybody help me for this?
code
public void postFb(){ String path = "me/feed";
AccessToken at = AccessToken.getCurrentAccessToken();
Bundle parameters = new Bundle();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Const.bmp_post.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
parameters.putByteArray("picture", byteArray);
HttpMethod method = HttpMethod.POST;
GraphRequest.Callback cb = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Log.d("=======graph response=======" , graphResponse.toString());
//check graphResponse for success or failure
if(graphResponse.getError()==null){
Toast.makeText(NewPostActivity.this, "Successfully posted to Facebook", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(NewPostActivity.this, "Facebook: There was an error, Please Try Again", Toast.LENGTH_SHORT).show();
}
}
};
GraphRequest request = new GraphRequest(at,path,parameters,method,cb);
request.setParameters(parameters);
request.executeAsync();
}
尝试将"/me/feed"
更改为"me/photos"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.