如何post把Theta 360度照片发到facebook
How to post the Theta 360 degree photo to facebook
我正在使用Theta Camera SDK 360 度拍照
我想 post 这张照片到 Facebook 这是 360 照片。
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);
它已成功 post 在 Facebook 上发布,但视图是这样的
我正在用 ._er_injected 更改扩展名,但出现同样的问题。
也使用此代码
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();
我想我调用 API 的方式有误。
终于通过 Read this Link 和 Facebook
的调用图 Api 找到了解决方案
以及更多阅读来自 This Facebook reference
的有关此球的信息
从两个链接和相应的更改中仔细阅读 ProjectionType、CroppedAreaImageWidthPixels 等内容
取的Size是Same Size of Image which (5376*2688)所以按Image width height取size
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();
}
我正在使用Theta Camera SDK 360 度拍照
我想 post 这张照片到 Facebook 这是 360 照片。
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);
它已成功 post 在 Facebook 上发布,但视图是这样的
我正在用 ._er_injected 更改扩展名,但出现同样的问题。
也使用此代码
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();
我想我调用 API 的方式有误。
终于通过 Read this Link 和 Facebook
的调用图 Api 找到了解决方案以及更多阅读来自 This Facebook reference
的有关此球的信息从两个链接和相应的更改中仔细阅读 ProjectionType、CroppedAreaImageWidthPixels 等内容
取的Size是Same Size of Image which (5376*2688)所以按Image width height取size
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();
}