我正在尝试在专门针对Windows Phone平台的Phonegap应用程序上执行Facebook登录。
我已经在https://github.com/purplecabbage/phonegap-plugins/tree/master/WindowsPhone下载了必需的插件(文件:ChildBrowserCommand.cs,ChildBrowser.js)和FBConnect.js。我还将ChildBrowser.cs文件包含在我的项目中
下面是我简单的html文件。一段时间后,我想进行Facebook登录:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" />
<script type="text/javascript" charset="utf-8" src="js/jquery/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript" src="js/run/cordova.js"></script>
<script type="text/javascript" src="js/utils/ChildBrowser.js"></script>
<script type="text/javascript" src="js/utils/FBConnect.js"></script>
<title></title>
</head>
<body>
<script>
$.support.cors = true;
</script>
<div id="testPage" data-role="page">
<script>
setTimeout(function () {
var client_id = "...";
var redir_url = "http://www.facebook.com/connect/login_success.html";
var friendsMap = {};
var fb = FBConnect.install(client_id, redir_url, "touch");
fb.connect('email, read_stream, read_friendlists');
fb.onConnect = onFBConnected;
}, 2500);
function onFBConnected() {
}
</script>
<div data-role="content">
</div>
</div>
</body>
</html>
但是当我编译项目时,我遇到了以下错误:
1. The type or namespace name 'BaseCommand' could not be found
2. The type or namespace name 'JSON' does not exist in the namespace 'WP7CordovaClassLib.Cordova'
关于第一个错误,我看到ChildBrowserCommand.cs文件中存在不正确的命名空间。我已经解决了这个问题,但我不知道在哪里可以找到丢失的JSON模块。从存档下载Phonegap 2.9.1后,有可能创建Visual Studio模板(在解压缩后的lib / windows-phone目录下,我已经完成了),但似乎库可能不完整。还有一个错误,我无法执行我的Facebook登录。你遇到过这个问题吗?哪里可以找到这个缺失的模块?下面是我的ChildBrowserCommand.cs更改。我将不胜感激任何帮助!
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Diagnostics;
using System.Runtime.Serialization;
using WP7CordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands; // previous: using WP7CordovaClassLib.Cordova.Commands;
using WP7CordovaClassLib.Cordova.JSON; // it's missing
using Microsoft.Phone.Shell;
答案 0 :(得分:0)
更新:前段时间我找到了非常好的解决方案HERE。它适用于我的Windows Phone应用程序!为了正确执行Facebook登录,您需要在Phonegap项目中设置InAppBrowser插件,并在 .FaceGap 方法调用之前输入您的App ID和App Secret密钥。辉煌! :)