Facebook的SDK无法生成preVIEW用户只有当opengraphobject.setproperty(" OG:网址")设置网址、用户、SDK、preVIEW

2023-09-05 03:10:28 作者:你好萌

我有一个应用程序,我想在Facebook上分享的历史。我没有网络我的应用程序。我只是想与大家分享的标题和描述中的形象,如果它是更多钞票,当点击共享网站上,他们重新定向到谷歌播放下载的应用程序或Facebook应用程序页面。

I have an app where I want to share a history in facebook. I don't have a web for my application. I only want to share an image with title and description and if it's posible that when click on the shared site they redirect to google play to download app or to facebook app page.

我看在大多数Facebook的样品和这里的答案,有件事我做错了肯定。 我把所有的Facebook应用程序配置。重点哈希,等等......我创建的Open Graph的历史称为Publicar一个卢格。行动=Publicar对象=卢格。

I look for an answer in most of facebook samples and here and there is something that I'm doing wrong for sure. I made all the facebook app configuration. Key hashes, etc... I create a history in open graph called Publicar a Lugar. Action="Publicar" Object="Lugar".

我有这个code

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", "https://m.xsw88.com/allimgs/daicuo/20230905/882.png.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()); 
}

我有两个diferent错误在我的智能手机调试:

I have two diferent errors debugging in my smartphone:

1,如果我取消这一条线路

1- if I uncomment one of this lines

//oplugar.setProperty("og:image", "https://m.xsw88.com/allimgs/daicuo/20230905/882.png.jpg");
//oplugar.setProperty("og:url", "http://www.udg.edu/");

我有一个错误,指出com.facebook.FacebookException:无法生成preVIEW用户。我不能推杆的网址

I have an error that says "com.facebook.FacebookException: Failed to generate preview for user.". I can't putt an url

2 - 如果我想添加一个自定义图像。如果我取消这个code

2- If I want to add a custom image. If I uncomment this code

//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);

我有一个黑色的窗口,有些事情似乎重新启动......

I have a black window and something seems to be restarted...

02-08 15:09:46.500:W / GAV3(15911):螺纹[GAThread,5,主]:服务不可用(code = 1),   将重试。   02-08 15:09:46.500:I / GAV3(15911):螺纹[GAThread,5,主]:无   活动数据中发现。 02-08 15:09:48.482:D / AbsListView(15911):   unregisterIRListener()被调用02-08 15:09:48.982:   D / AbsListView(15911):onVisibilityChanged()被调用,能见度:4   02-08 15:09:48.982:D / AbsListView(15911):unregisterIRListener()是   所谓的02-08 15:09:51.525:W / GAV3(15911):螺纹[服务   重新连接,5,主]:服务不可用(code = 1),使用本地存储。   02-08 15:09:53.778:D / AbsListView(16092):获取MotionRecognitionManager   02-08 15:09:53.778:D / AbsListView(16092):onVisibilityChanged()是   所谓的,能见度:8月2日至八日15:09:53.778:D / AbsListView(16092):   unregisterIRListener()被调用02-08 15:09:53.788:   D /进度(16092):setProgress = 0 02-08 15:09:53.788:   D /进度(16092):setProgress = 0,FROMUSER =假02-08   15:09:53.788:D /进度(16092):mProgress = 0mIndeterminate =   假的,MMIN = 0,M最大= 10000 02-08 15:09:53.828:   D / AbsListView(16092):onVisibilityChanged()被调用,能见度:4   02-08 15:09:53.828:D / AbsListView(16092):unregisterIRListener()是   所谓的02-08 15:09:53.838:D / AbsListView(16092):   onVisibilityChanged()被调用时,可见性:0 02-08 15:09:53.838:   D / AbsListView(16092):unregisterIRListener()被调用02-08   15:09:53.848:D / libEGL(16092):加载   /system/lib/egl/libEGL_adreno200.so 02-08 15:09:53.858:   D / libEGL(16092):加载/system/lib/egl/libGLESv1_CM_adreno200.so   02-08 15:09:53.858:D / libEGL(16092):加载   /system/lib/egl/libGLESv2_adreno200.so 02-08 15:09:53.858:   我/的Adreno200东瀛(16092):EGL 1.4   高通公司编译:

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:我/的Adreno200东瀛(16092):建立日期:   13年5月17日星期五02-08 15:09:53.858:我/的Adreno200东瀛(16092):本地分公司:   02-08 15:09:53.858:我/的Adreno200东瀛(16092):远程分支:   QUIC / jb_2.5.5 02-08 15:09:53.858:我/的Adreno200东瀛(16092):本地   补丁:34c9e193f12610d3e68dabd6198d2c4bfbc66974 RB:更新   主

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 master

在hw_image的rb_texture_update_aliased 02-08时间戳   15:09:53.858:我/的Adreno200东瀛(16092):重建分公司:   AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023 + 01d3c78 +

timestamp 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):启用调试模式0 02-08 15:09:53.878:   D /进度(16092):updateDrawableBounds:左= 0 02-08   15:09:53.878:D /进度(16092):updateDrawableBounds:顶部= 0   02-08 15:09:53.878:D /进度(16092):updateDrawableBounds:右   = 72 02-08 15:09:53.878:D /进度(16092):updateDrawableBounds:底部= 72 02-08 15:09:54.058:I /系统(16092):加载时区   09:54.088在217ms(在ICU 205ms)02-08 15恩的名字:   D / AbsListView(16092):onVisibilityChanged()被调用时,可见性:0   02-08 15:09:54.088:D / AbsListView(16092):unregisterIRListener()是   所谓的02-08 15:09:54.168:D / AbsListView(16092):   unregisterIRListener()被调用02-08 15:09:54.178:   D / AbsListView(16092):unregisterIRListener()被调用02-08   15:09:54.188:E / ViewRootImpl(16092):sendUserActionEvent()== MVIEW   空02-08 15:09:54.268:D / AbsListView(16092):unregisterIRListener()   被称为02-08 15:09:58.833:W / GAV3(16092):螺纹[GAThread,5,主]:   服务不可用(code = 1),将重试。 02-08 15:09:58.833:   I / GAV3(16092):螺纹[GAThread,5,主]:无运动数据发现。 02-08   15:10:03.838:W / GAV3(16092):螺纹[服务重新连接,5,主]:服务   不可用(code = 1),使用本地存储。 02-08 15:10:10.565:   D / AbsListView(16092):unregisterIRListener()被调用

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

和显示previous活动。

and display the previous activity.

通过上面的code sharedialog显示我的Facebook对话,我可以分享。但是,如果没有链接,没有我的形象。

With the above code sharedialog shows me the facebook dialog and I can share. But without link and without my image.

您能帮我吗?我已经尝试了很多不同的东西!

Can you help me? I've tried a lot of different things!

这是我的智能手机? Facebook的版本?

it's my smartphone? facebook version?

你有一个简单的示例共享自定义(用户制作)图像的共享对话框的说明?

Do you have a simple sample to share a custom (made for user) image with a description in a share dialog?

谢谢,对不起我的英语水平。

Thanks and sorry for my english.

推荐答案

如果你没有一个Web组件,那么就不要设置在OG对象的URL。如果设置了一个网址,Facebook将尝试去凑那个网址,如果从那里刮了OG元数据不匹配,你所提供的东西,那么它就会失败。

If you don't have a web component, then do not set a url in the og object. If you set a url, facebook will try to go scrape that url, and if the OG metadata scraped from there doesn't match what you've provided, then it will fail.

如果您希望将位图添加到您的OG行动,除了你目前正在做的,则还必须NativeAppCallContentProvider添加到您的清单。在这里看到的文档:https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/这是Facebook应用程序如何能真正得到你想要发送的位图。

If you want to add a bitmap to your OG action, in addition to what you're currently doing, you must also add a NativeAppCallContentProvider to your manifest. See the docs here: https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/ This is how the Facebook app can actually get the bitmaps you're trying to send.

最后,看看在美味的示例应用程序附带的SDK。它有一个选项(如果跳过登录),创建一个新的OG的对象,带有图像附件。

Lastly, have a look at the Scrumptious sample app that ships with the sdk. It has an option (if you "skip login") that creates a new OG object, with an image attachment.