3
어쩌면 어리석은 질문 일 수도 있지만 해결할 수는 없습니다. Phonegap Build에서 일하고 있으며 앱에 Facebook 로그인을 추가하려고합니다. 하지만 플러그인이 작동하지 않는 것 같습니다!phonegap 빌드 및 Facebook 플러그인
여기에 오류가 표시됩니다. "Cordova Facebook Connect Plugin on init!" 3.1.0 나는 (아마도 당신에게 아이디어를 제공) 여기가 내가 사용하는 간단한 코드입니다 수화를 사용하십시오 :
자세한 내용은 내 폰갭 버전은 여기
<html>
<head>
</head>
<body>
<button onclick="login()">Login</button>
<button onclick="me()">Me</button>
<!--<button onclick="getSession()">Get session</button>-->
<button onclick="getLoginStatus()">Get login</button>
<button onclick="logout()">Logout</button>
<button onclick="facebookWallPost()">facebookWallPost</button>
<button onclick="publishStoryFriend()">friendstory</button>
<div id="data">loading ...</div>
<!--<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
<div id="fb-root"></div>-->
<!-- cordova -->
<script src="cordova.js"></script>
<!-- cordova facebook plugin -->
<script src="cdv-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="facebook-js-sdk.js"></script>
<script>
<!-- These are the notifications that are displayed to the user through pop-ups if the above JS files does not exist in the same directory-->
if ((typeof cordova == 'undefined') && (typeof Cordova == 'undefined')) alert('Cordova variable does not exist. Check that you have included cordova.js correctly');
if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly');
if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');
FB.Event.subscribe('auth.login', function(response) {
alert('auth.login event');
});
FB.Event.subscribe('auth.logout', function(response) {
alert('auth.logout event');
});
FB.Event.subscribe('auth.sessionChange', function(response) {
alert('auth.sessionChange event');
});
FB.Event.subscribe('auth.statusChange', function(response) {
alert('auth.statusChange event');
});
/*function getSession() {
alert("session: " + JSON.stringify(FB.getSession()));
}
*/
function getLoginStatus() {
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
alert('logged in');
} else {
alert('not logged in');
}
});
}
var friendIDs = [];
var fdata;
function me() {
FB.api('/me/friends', { fields: 'id, name, picture' }, function(response) {
if (response.error) {
alert(JSON.stringify(response.error));
} else {
var data = document.getElementById('data');
fdata=response.data;
console.log("fdata: "+fdata);
response.data.forEach(function(item) {
var d = document.createElement('div');
d.innerHTML = "<img src="+item.picture+"/>"+item.name;
data.appendChild(d);
});
}
var friends = response.data;
console.log(friends.length);
for (var k = 0; k < friends.length && k < 200; k++) {
var friend = friends[k];
var index = 1;
friendIDs[k] = friend.id;
//friendsInfo[k] = friend;
}
console.log("friendId's: "+friendIDs);
});
}
function logout() {
FB.logout(function(response) {
alert('logged out');
});
}
function login() {
FB.login(
function(response) {
if (response.session) {
alert('logged in');
} else {
alert('not logged in');
}
},
{ scope: "email" }
);
}
function facebookWallPost() {
console.log('Debug 1');
var params = {
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
};
console.log(params);
FB.ui(params, function(obj) { console.log(obj);});
}
function publishStoryFriend() {
randNum = Math.floor (Math.random() * friendIDs.length);
var friendID = friendIDs[randNum];
if (friendID == undefined){
alert('please click the me button to get a list of friends first');
}else{
console.log("friend id: " + friendID);
console.log('Opening a dialog for friendID: ', friendID);
var params = {
method: 'feed',
to: friendID.toString(),
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
};
FB.ui(params, function(obj) { console.log(obj);});
}
}
document.addEventListener('deviceready', function() {
try {
alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "[myAppID]", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
</script>
<div id="log"></div>
</body>
</html>
내 설정입니다. xml 파일 :
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/3.3.0" id = "com.phonegap.polimiSajjad" version = "0.0.3">
<preference name="phonegap-version" value="3.1.0" />
<name>Sajjad App v0.0.4</name>
<description>just a test app</description>
<author href="sajjadsalehi.webadua.com" email="[email protected]">sajjad salehi</author>
<preference name="orientation" value="portrait" />
<preference name="fullscreen" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.device-motion" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="com.phonegap.plugins.facebookconnect">
<param name="APP_ID" value="[myAppID]" />
<param name="APP_NAME" value="Polimi Students Market" />
</gap:plugin>
<icon src="icon.jpg" />
</widget>
아마도 내가 Facebook의 앱 설정에서 패키지 이름을 설정하는 데 문제가 있습니다. 페이스 북 설정에 입력해야하는 패키지의 이름은 누구에게 어떤 생각이 있습니까? 감사합니다 –
페이 스북 설정 패키지의 이름은 com.phonegap.polimiSajjad, 즉 config.xml의 위젯 태그 ID입니다. – Bimal