我有一个应用程序,我想在Facebook上分享历史记录.我的应用程序没有网页.我只想分享带有标题和描述的图像,如果可以点击共享网站,他们会重定向到谷歌播放下载应用程序或Facebook应用程序页面.
我在大多数facebook样本中寻找答案,这里有一些我肯定做错的事情.
我做了所有的Facebook应用程序配置.关键哈希等…我在开放图形中创建一个名为Publicar a Lugar的历史. Action =“Publicar”Object =“Lugar”.
private void OpenShareDialog(){
Session session = Session.getActiveSession();
if (session != null) {
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetof(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
}
OpenGraphObject oplugar = OpenGraphObject.Factory.createForPost("namespace:lugar");
oplugar.setProperty("og:type","namespace:lugar");
oplugar.setProperty("og:title", LugarCargado.getNombre());
//oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg");
//oplugar.setProperty("og:url", "http://www.udg.edu/");
oplugar.setProperty("og:description", LugarCargado.getDescripcion());
//Bitmap bitmap;
//List<Bitmap> bitmaps = new ArrayList<Bitmap>();
//bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2);
//Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth());
//bitmaps.add(bitmap);
//OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
OpenGraphAction action = OpenGraphAction.Factory.createForPost("namespace:publicar");
action.setProperty("lugar", oplugar);
action.setType("namespace:publicar");
action.setProperty("previewPropertyName", oplugar);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "lugar")
//.setimageAttachmentsForObject("lugar", bitmaps, true)
//.setimageAttachmentsForAction(bitmaps,true);
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
我在智能手机中调试了两个不同的错误:
1-如果我取消注释其中一行
//oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg");
//oplugar.setProperty("og:url", "http://www.udg.edu/");
我有一个错误,上面写着“com.facebook.FacebookException:无法为用户生成预览.”.我不能推动网址
//Bitmap bitmap;
//List<Bitmap> bitmaps = new ArrayList<Bitmap>();
//bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2);
//Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth());
//bitmaps.add(bitmap);
和
//.setimageAttachmentsForAction(bitmaps,true);
02-08 15:09:46.500: W/GAV3(15911): Thread[GAThread,5,main]: Service unavailable (code=1),
will retry.
02-08 15:09:46.500: I/GAV3(15911): Thread[GAThread,5,main]: No
campaign data found. 02-08 15:09:48.482: D/AbsListView(15911):
unregisterIRListener() is called 02-08 15:09:48.982:
D/AbsListView(15911): onVisibilityChanged() is called, visibility : 4
02-08 15:09:48.982: D/AbsListView(15911): unregisterIRListener() is
called 02-08 15:09:51.525: W/GAV3(15911): Thread[Service
Reconnect,5,main]: Service unavailable (code=1), using local store.
02-08 15:09:53.778: D/AbsListView(16092): Get MotionRecognitionManager
02-08 15:09:53.778: D/AbsListView(16092): onVisibilityChanged() is
called, visibility : 8 02-08 15:09:53.778: D/AbsListView(16092):
unregisterIRListener() is called 02-08 15:09:53.788:
D/ProgressBar(16092): setProgress = 0 02-08 15:09:53.788:
D/ProgressBar(16092): setProgress = 0, fromUser = false 02-08
15:09:53.788: D/ProgressBar(16092): mProgress = 0mIndeterminate =
false, mMin = 0, mMax = 10000 02-08 15:09:53.828:
D/AbsListView(16092): onVisibilityChanged() is called, visibility : 4
02-08 15:09:53.828: D/AbsListView(16092): unregisterIRListener() is
called 02-08 15:09:53.838: D/AbsListView(16092):
onVisibilityChanged() is called, visibility : 0 02-08 15:09:53.838:
D/AbsListView(16092): unregisterIRListener() is called 02-08
15:09:53.848: D/libEGL(16092): loaded
/system/lib/egl/libEGL_adreno200.so 02-08 15:09:53.858:
D/libEGL(16092): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
02-08 15:09:53.858: D/libEGL(16092): loaded
/system/lib/egl/libGLESv2_adreno200.so 02-08 15:09:53.858:
I/Adreno200-EGL(16092): : EGL 1.4
QUALCOMM build:AYELDER_AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023+PATCH[ES]_msm8960_JB_2.5.5_CL3556704_release_ENGG (CL3556704) 02-08 15:09:53.858: I/Adreno200-EGL(16092): Build Date:
05/17/13 Fri 02-08 15:09:53.858: I/Adreno200-EGL(16092): Local Branch:
02-08 15:09:53.858: I/Adreno200-EGL(16092): Remote Branch:
quic/jb_2.5.5 02-08 15:09:53.858: I/Adreno200-EGL(16092): Local
Patches: 34c9e193f12610d3e68dabd6198d2c4bfbc66974 RB: Update the
mastertimestamp of the hw_image in rb_texture_update_aliased 02-08
15:09:53.858: I/Adreno200-EGL(16092): Reconstruct Branch:
AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023 + 01d3c78 +e6f0547 + LOCAL_PATCH[ES] 02-08 15:09:53.878:
D/Openglrenderer(16092): Enabling debug mode 0 02-08 15:09:53.878:
D/ProgressBar(16092): updateDrawableBounds: left = 0 02-08
15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: top = 0
02-08 15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: right
= 72 02-08 15:09:53.878: D/ProgressBar(16092): updateDrawableBounds: bottom = 72 02-08 15:09:54.058: I/System(16092): Loaded time zone
names for en in 217ms (205ms in ICU) 02-08 15:09:54.088:
D/AbsListView(16092): onVisibilityChanged() is called, visibility : 0
02-08 15:09:54.088: D/AbsListView(16092): unregisterIRListener() is
called 02-08 15:09:54.168: D/AbsListView(16092):
unregisterIRListener() is called 02-08 15:09:54.178:
D/AbsListView(16092): unregisterIRListener() is called 02-08
15:09:54.188: E/ViewRootImpl(16092): sendUserActionEvent() mView ==
null 02-08 15:09:54.268: D/AbsListView(16092): unregisterIRListener()
is called 02-08 15:09:58.833: W/GAV3(16092): Thread[GAThread,5,main]:
Service unavailable (code=1), will retry. 02-08 15:09:58.833:
I/GAV3(16092): Thread[GAThread,5,main]: No campaign data found. 02-08
15:10:03.838: W/GAV3(16092): Thread[Service Reconnect,5,main]: Service
unavailable (code=1), using local store. 02-08 15:10:10.565:
D/AbsListView(16092): unregisterIRListener() is called
使用上面的代码,sharedialog向我展示了facebook对话框,我可以分享.但没有链接,没有我的形象.
你能帮助我吗?我尝试了很多不同的东西!
这是我的智能手机? facebook版本?
您是否有一个简单的示例来共享自定义(为用户制作)图像以及共享对话框中的描述?
谢谢,抱歉我的英语.
解决方法:
如果您没有Web组件,则不要在og对象中设置URL.如果您设置了一个网址,Facebook会尝试抓取该网址,如果从那里抓取的OG元数据与您提供的内容不匹配,则会失败.
如果要向OG操作添加位图,除了当前正在执行的操作之外,还必须向清单添加NativeAppCallContentProvider.请参阅此处的文档:https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/这是Facebook应用程序实际获取您尝试发送的位图的方式.
最后,看看sdk附带的ScrumptIoUs示例应用程序.它有一个选项(如果你“跳过登录”),它创建一个带有图像附件的新OG对象.