I am using the Theta Camera SDK to take the picture in 360 degrees.
I want to post this photo to Facebook this is 360 photo.
String path= "/storage/emulated/0/path/imagebitmap.jpg";
SharePhoto photo = new SharePhoto.Builder()
.setImageUrl(Uri.fromFile(new File(path)))
.setCaption("")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content,shareCallback);
It was Successfully posted on facebook but view like that
I am changing the extension with ._er_injected but the same problem occurs.
Also Use this Code
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.imagebitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle params = new Bundle();
/*spherical_metadata*/
String mjson="{\"ProjectionType\": \"equirectangular\",\"CroppedAreaImageWidthPixels\": 240,\"CroppedAreaImageHeightPixels\": 240,\"FullPanoWidthPixels\": 1962,\"FullPanoHeightPixels\": 981,\"CroppedAreaLeftPixels\": 981,\"CroppedAreaTopPixels\": 490}";
params.putByteArray("picture", byteArray);
params.putBoolean("allow_spherical_photo", true);
params.putString("spherical_metadata", mjson);
params.putString("name", "Panorama images");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/photos",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.e("@@@response", String.valueOf(response));
// Toast.makeText()
}
}
).executeAsync();
I think I am calling API in wrong way.
Finally Got the Solution by Read this Link and Call graph Api of Facebook
And more Read about this spherical from This Facebook reference
Read Carefully about the ProjectionType, CroppedAreaImageWidthPixels etc from both links and changes made Accordingly
The Size is taken are the Same Size of Image which (5376*2688) so take the size according to Image width height
private void sharePhotoToFacebook(){
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.imagebitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle params = new Bundle();
JSONObject json= new JSONObject();
try {
json.put("ProjectionType", "equirectangular");
json.put("CroppedAreaImageWidthPixels", 5376);
json.put("CroppedAreaImageHeightPixels", 2688);
json.put("FullPanoWidthPixels", 5376);
json.put("FullPanoHeightPixels", 2688);
json.put("CroppedAreaLeftPixels", 0);
json.put("CroppedAreaTopPixels", 0);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONObject jsonObject=new JSONObject();
params.putByteArray("picture", byteArray);
params.putBoolean("allow_spherical_photo", true);
params.putString("spherical_metadata", json.toString());
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/photos",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.e("@@@response", String.valueOf(response));
Toast.makeText(getApplicationContext(),"Snapshot shared On Facebook",Toast.LENGTH_SHORT).show();
}
}
).executeAsync();
}