2014-09-11 79 views
0

我在使用网页对话框时遇到了facebook共享中的一些问题,Facebook提示错误消息”发生错误,请稍后再试。“ onCompleteListener是越来越单击OK(确定)错误消息对话框后调用。我无法找到的错误代码。在Android上使用Web对话框在Facebook共享上发生错误“发生错误,请稍后再试

相同的应用程序是为Facebook原生对话框正常工作。

我自己也尝试相同的代码不同Facebook的应用程序ID,它工作的很好,所以它没有看到任何代码相关的问题,但与Facebook上的应用程序设置有关

在我的应用程序ID中,我设置了应用程序域,网站网址和移动网站网址。如果我们正在设置应用程序域,网站网址和移动网站网址,我们是否也需要发送其他一些参数?

请提出一些解决方案。

Bundle params = new Bundle(); 
    params.putString("name", mShareText); 
    params.putString("caption","Build"); 
    params.putString("description", mContext.getString(R.string.social_preconfigured_text));  
    params.putString("link", mShareUrl); 

    if(mShareImageUrl!=null){ 
     params.putString("picture", mShareImageUrl); 
    } 
    else{ 
     params.putString("picture", " "); 
    } 

    // Invoke the dialog 
    WebDialog feedDialog = (
      new WebDialog.FeedDialogBuilder(this, 
        Session.getActiveSession(), 
        params)) 
        .setOnCompleteListener(new OnCompleteListener() { 
         @Override 
         public void onComplete(Bundle values, FacebookException error) { 
          if (error == null) { 
           Toast.makeText(mContext, mContext.getString(R.string.social_success_text), Toast.LENGTH_SHORT).show(); 
          } 
          else{ 
           Toast.makeText(mContext, mContext.getString(R.string.social_failure_text), Toast.LENGTH_SHORT).show(); 
          } 
         } 
        }).build(); 
    feedDialog.show(); 

感谢, 马尼什

+0

你可以尝试修改你的问题的标题,并给予一定的代码? – Raptor 2014-09-11 07:41:09

回答

1

难治说没有错误或代码,但我使用Facebook对话,如:

@Override 
    public void requestPostDialog(Bundle bundle, OnPostingCompleteListener onPostingCompleteListener) { 
     super.requestPostDialog(bundle, onPostingCompleteListener); 
     if (FacebookDialog.canPresentShareDialog(mSocialNetworkManager.getActivity(), 
       FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) { 
      FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(mSocialNetworkManager.getActivity()) 
        .setLink(bundle.getString(BUNDLE_LINK)) 
        .setDescription(bundle.getString(BUNDLE_MESSAGE)) 
        .setName(bundle.getString(BUNDLE_NAME)) 
        .setApplicationName(bundle.getString(BUNDLE_APP_NAME)) 
        .setCaption(bundle.getString(BUNDLE_CAPTION)) 
        .setPicture(bundle.getString(BUNDLE_PICTURE)) 
//     .setFriends(bundle.getStringArrayList(DIALOG_FRIENDS)) 
        .build(); 
      mUILifecycleHelper.trackPendingDialogCall(shareDialog.present()); 
     } else { 
      publishFeedDialog(bundle); 
     } 
    } 

    private void publishFeedDialog(Bundle bundle) { 
     Bundle params = new Bundle(); 
     params.putString("name", bundle.getString(BUNDLE_NAME)); 
     params.putString("caption", bundle.getString(BUNDLE_CAPTION)); 
     params.putString("description", bundle.getString(BUNDLE_MESSAGE)); 
     params.putString("link", bundle.getString(BUNDLE_LINK)); 
     params.putString("picture", bundle.getString(BUNDLE_PICTURE)); 

     WebDialog feedDialog = (
       new WebDialog.FeedDialogBuilder(mSocialNetworkManager.getActivity(), 
         Session.getActiveSession(), 
         params)) 
       .setOnCompleteListener(new WebDialog.OnCompleteListener() { 
        @Override 
        public void onComplete(Bundle values, 
              FacebookException error) { 
         if (error == null) { 
          final String postId = values.getString("post_id"); 
          if (postId != null) { 
           ((OnPostingCompleteListener) mLocalListeners.get(REQUEST_POST_DIALOG)).onPostSuccessfully(getID()); 
          } else { 
           mLocalListeners.get(REQUEST_POST_DIALOG).onError(getID(), 
             REQUEST_POST_DIALOG, "Canceled", null); 
          } 
         } else { 
          mLocalListeners.get(REQUEST_POST_DIALOG).onError(getID(), 
            REQUEST_POST_DIALOG, "Canceled: " + error.toString(), null); 
         } 
         mLocalListeners.remove(REQUEST_POST_DIALOG); 
        } 
       }) 
       .build(); 
     feedDialog.show(); 
    } 
+0

@Ekondard,我添加了我的代码片段。请建议如何检查错误代码。在onComplete中,我没有收到任何错误代码。只有在错误对话框中单击确定后才会调用它。 – Manish 2014-09-11 08:34:57

+0

最后我得到了解决方案。在Facebook应用程序设置 - >迁移选项卡中,有人设置了流发布URL安全切换。正因为如此,我正面临着这个问题。 – Manish 2014-09-15 04:45:03

+0

你是说WebDialog取决于FB APK吗?从https://developers.facebook.com/docs/android/share#linkfeed“如果用户没有安装Facebook for Android应用程序,则无法显示共享对话框。在这种情况下,我们建议您回到Feed对话框,一个不需要安装Facebook应用程序的网页对话框。“ – John 2014-09-17 13:23:26

相关问题