Android Post Picture to Facebook Wall

Android post picture to Facebook wall

first thing is that you are not using graph api to upload the pictures... u r using the old rest api... try to use graph api, its simple...

Use following code:

Bundle param = new Bundle();
param.putString("message", "picture caption");
param.putByteArray("picture", ImageBytes);
mAsyncRunner.request("me/photos", param, "POST", new SampleUploadListener());

According to error message, it looks like its giving errors in getting bytes from intent's bundle...

Post a picture to the wall from android

The accepted answer in the 1st thread is correct, with just one change, you see when you upload a picture in facebook, like in the screen capture you added, you post it to a specific album titled "Wall Photos".

In that answer they used me/photos, and that will create an album for the app (if one isn't already existing) and post the image there.

I think that this should work:

Bundle params = new Bundle();
params.putByteArray("source", imageBytes);
params.putString("message", "A wall picture");
facebook.request("me/feed", params, "POST");

(you can obviously use the async runner)

If that does not work, then you'll have to get the "wall photos" album id of the logged in user first and then do something like:

Bundle params = new Bundle();
params.putByteArray("source", imageBytes);
params.putString("message", "A wall picture");
facebook.request("ALBUM_ID/photos", params, "POST");

How to submit Photos with text together to Facebook wall from Android?

In the documentation of the User object, it says under the photos connection:

You can post photos to a user's Wall on their behalf by issuing an
HTTP POST request to PROFILE_ID/photos with the publish_stream
permissions and the following parameters.

The android fb sdk will do just that for you, it should look something like this:

// facebook being either Facebook or AsyncFacebookRunner

Bundle parameters = new Bundle();
parameters.putString("message", "MESSAGE TO GO WITH THE IMAGE");
parameters.putByteArray("source", imageBytes);

facebook.request("me/photos", parameters, "POST");

I haven't tested it, and kind of "glued" it together after reading the documentation, the source and some threads (Async API Requests, API Requests, Facebook.java, Util.java, Android post picture to Facebook wall). In the last link in the code it says that the parameter name is picture instead of the source that I used, but that's how it states in the documentation, check it out and see which one works.

Also, you can use USER-ID/photoes instead of the me/photos graph object path, just make sure that you have the publish_stream permission.

Next time you ask a question, try to be more specific, maybe add the code you have so far?

Facebook wall post with text and image

you can post your image with text from your application in a very simply way.

Call this method while clicking on the button widget say btnImagePostToWall like...

btnImagePostToWall.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

postImageToWall();
}
});

Get Profile information by making request to Facebook Graph API....

public void postImageToWall() {

facebook.authorize(
this,
new String[] { "user_photos,publish_checkins,publish_actions,publish_stream" },
new DialogListener() {

@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}

@Override
public void onError(DialogError dialogError) {
// TODO Auto-generated method stub
}

@Override
public void onComplete(Bundle values) {
postImageonWall();
}

@Override
public void onCancel() {
// TODO Auto-generated method stub
}
});
}

private void postImageonWall() {
byte[] data = null;

Bitmap bi = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, facebook.getAccessToken());
params.putString("method", "photos.upload");
params.putByteArray("picture", data); // image to post
params.putString("caption", "My text on wall with Image "); // text to post
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new SampleUploadListener(),
null);
}

Just create a class SampleUploadListener which implements AsyncFacebookRunner.RequestListener...

class SampleUploadListener implements AsyncFacebookRunner.RequestListener {

@Override
public void onComplete(String response, Object state) {
}

@Override
public void onIOException(IOException e, Object state) {
}

@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}

@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}

@Override
public void onFacebookError(FacebookError e, Object state) {
}

}

Hope this will help you a bit.... :-)

Post picture on facebook wall from drawable/assets android

The "picture" value must be a URL. It cannot be binary data.

Android facebook SDK, upload pictures to wall with profile in different language?

Post your code how you are uploading image to facebook. And this is one sample code which is working fine for me just have a look might be helpful to you. And in my code am not creating any album Wall Photos. My picture gets uploaded in wall itself. Just have a look ...

private void fbImageSubmit() {
if (facebook != null) {
if (facebook.isSessionValid()) {
try {
byte[] data = null;

// Bitmap bi = BitmapFactory.decodeFile(Constants.imgShare);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

bmScreen.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();

Bundle parameters = new Bundle();
parameters.putString("message", strmsg);
parameters.putString("method", "photos.upload");
parameters.putByteArray("picture", data);

facebook.request(null, parameters, "POST");
/*
* time = Calendar.getInstance().getTime().getHours() + ":"
* + Calendar.getInstance().getTime().getMinutes();
*/

currentTime = DateFormat.format("hh:mm", d.getTime());
currentDate = DateFormat.format("dd/MM/yyyy", d.getTime());

Cursor cursor = Constants.dbHelper
.GetDataFromImageName(Constants.enhancedImage
.getImagename());
if (cursor.getCount() > 0) {
Constants.dbHelper.updateData(currentDate.toString(),
currentTime.toString(), "Facebook", "Image");
} else {
Constants.dbHelper.insertData("true");
}
Toast.makeText(getApplicationContext(),
"Image uploaded successfully.", Toast.LENGTH_LONG)
.show();

} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
}
}

// bmscreen is my bitmap of image ;
Hope might be helpful to you.



Related Topics



Leave a reply



Submit