UNPKG

phonegap-facebook-plugin

Version:

The official Facebook plugin for Apache Cordova/PhoneGap

88 lines (80 loc) 4.37 kB
<!DOCTYPE html> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> <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" /> <title>Hello World</title> </head> <body> <div class="app"> <h1>Apache Cordova</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> <div class="event listening button" onclick="login();">Login with Facebook</div> <div class="event listening button" onclick="showDialog();">Show Dialog with Facebook</div> <div class="event listening button" onclick="apiTest();">Test API with Facebook</div> <div class="event listening button" onclick="getAccessToken();">Get access token with Facebook</div> <div class="event listening button" onclick="getStatus();">Get login status with Facebook</div> <div class="event listening button" onclick="logout();">Logout with Facebook</div> </div> <div id="fb-root"></div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript"> var login = function () { if (window.cordova.platformId == "browser") { var appId = prompt("Enter FB Application ID", ""); facebookConnectPlugin.browserInit(appId); } facebookConnectPlugin.login( ["email"], function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } var showDialog = function () { facebookConnectPlugin.showDialog( { method: "feed" }, function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } var apiTest = function () { facebookConnectPlugin.api( "me/?fields=id,email", ["user_birthday"], function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } var getAccessToken = function () { facebookConnectPlugin.getAccessToken( function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } var getStatus = function () { facebookConnectPlugin.getLoginStatus( function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } var logout = function () { facebookConnectPlugin.logout( function (response) { alert(JSON.stringify(response)) }, function (response) { alert(JSON.stringify(response)) }); } </script> </body> </html>