Facebook Feed帖子的链接将在当前浏览器窗口中打开

时间:2012-08-24 17:08:57

标签: facebook facebook-graph-api facebook-android-sdk

我正在尝试使用Android SDK发布链接。

单击我的帖子锚点不会打开新的浏览器窗口,而是使用当前选项卡(Facebook个人资料/新闻源)。这导致用户丢失他/她的faecbook浏览器选项卡。

在我看来,这并不像预期的行为。其他应用程序(youtube,NewYorkTimes)会打开一个新选项卡。也许它在某种程度上是相关的,我的应用程序的网站网址画布网址都设置为Feed的链接属性指向的相同网址。

检查主播的来源,我发现它缺少target='_blank' HTML属性(youtube视频帖子确实具有该属性)。

编辑:

也许我没有说清楚...... 这里的问题不在于将订阅源发布到用户的墙上。只有在用户墙上点击该帖子(帖子的附加图片或链接)后,才能使用 Feed对话框成功发布此问题。执行此操作时,您将被重定向到当前浏览器选项卡上的链接地址(在Facebook外)。

编辑2:

我正在使用别人的代码,它是一个Cordova(Phonegap)facebook插件。

@Malione,我正在使用的完整代码可以在https://github.com/mgcrea/cordova-facebook-connect下找到。

我复制粘贴了一个可能是相关功能的功能 (位于src\com\facebook\android\Facebook.java下),并添加了2条可能也有帮助的日志行:

    /**
 * Cordova interface to display a dialog
 */
public PluginResult dialog(final JSONArray args, final String callbackId) throws JSONException, FileNotFoundException, MalformedURLException, IOException {
    Log.d(CLASS, "dialog() :" + args.toString());
    JSONObject params = args.getJSONObject(0);
    PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);

    final String method = params.has("method") ? params.getString("method") : "feed";
    JSONObject optionsObject = (JSONObject)params.get("params");
    final Bundle options = new Bundle();
    Iterator<?> keys = optionsObject.keys();
    while( keys.hasNext() ){
        String key = (String)keys.next();
        options.putString(key, optionsObject.getString(key));
        //if(optionsObject.get(key) instanceof JSONObject)
    }

    final FacebookConnect me = this;
    Runnable runnable = new Runnable() {
        public void run() {
            Log.d("Roei ------->>>>>>>Dialog options:", options.toString());
            Log.d("Roei ------->>>>>>>Dialog context:", me.cordova.getContext().toString() );
            me.getFacebook().dialog(me.cordova.getContext(), method, options, new RegularDialogListener(me, callbackId));
        };
    };
    pluginResult.setKeepCallback(true);
    this.cordova.getActivity().runOnUiThread(runnable);

    return pluginResult;
}

这是日志文件的输出:

08-28 20:21:18.015: D/CordovaLog(25340): picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg
08-28 20:21:18.015: D/CordovaLog(25340): : Line 1172087949 : picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg
08-28 20:21:18.015: I/Web Console(25340): picture: https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg at :1172087949
08-28 20:21:18.025: D/dalvikvm(25340): GC_CONCURRENT freed 395K, 49% free 3328K/6471K, external 598K/1065K, paused 6ms+3ms
08-28 20:21:18.035: D/FacebookConnect(25340): dialog() :[{"method":"feed","params":{"picture":"https:\/\/surf-space.com\/wp-content\/uploads\/spots\/user_reports\/default\/surf-report.jpg",
"method":"feed","description":"Wave height: 1.3 Meters<center \/>Surf conditions: Fine<center \/>","link":"https:\/\/surf-space.com\/spots\/israel\/","name":"Roei Bahumi posted a surf report for: Neurim, Netanya"}}]
08-28 20:21:18.035: D/Roei ------->>>>>>>Dialog options:(25340): Bundle[{picture=https://surf-space.com/wp-content/uploads/spots/user_reports/default/surf-report.jpg, method=feed, description=Wave height: 1.3 
Meters<center />Surf conditions: Fine<center />, name=Roei Bahumi posted a surf report for: Neurim, Netanya, link=https://surf-space.com/spots/israel/}]
08-28 20:21:18.035: D/DroidGap(25340): This will be deprecated December 2012
08-28 20:21:18.035: D/Roei ------->>>>>>>Dialog context:(25340): com.surf_space.surf_space4.MainActivity@405eb938
08-28 20:21:18.035: D/DroidGap(25340): This will be deprecated December 2012
08-28 20:21:19.897: W/InputManagerService(171): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40a82a20
08-28 20:21:28.125: D/FacebookConnect(25340): RegularDialogListener::onComplete() Bundle[{post_id=839443974_490613954283080}]
08-28 20:21:28.155: D/CordovaLog(25340): FacebookConnect.dialog:{"post_id":"839443974_490613954283080"}
08-28 20:21:28.155: D/CordovaLog(25340): : Line 1172088957 : FacebookConnect.dialog:{"post_id":"839443974_490613954283080"}
08-28 20:21:28.155: I/Web Console(25340): FacebookConnect.dialog:{"post_id":"839443974_490613954283080"} at :1172088957

这是你谈论的代码的一部分吗?您是否看到发送给Facebook的数据中缺少某些内容?

如果没有,请你指点我的Facebook Android SDK文档页面,解释如何设置target='_blank',甚至展示一个这样做的示例请求,我将不胜感激(并且还会知道是什么在代码中寻找)。

0 个答案:

没有答案