Facebook App Like server error? - facebook

I have a sample app that has a 'Like' button. It works before but now it doesn't.
I've tested this on jsfiddle.net before and it works too. But after I've uploaded my files on a server it has a bug. The 'Like' button pops up and then has this error:
https://www.facebook.com/plugins/error/confirm/like?iframe_referer=https%3A%2F%2Fns2383.hostgator.com%2F~caryucla%2Fbpcontest%2FHTML%2FContestHome.php%2F&secure=true&plugin=like&return_params=%7B%22api_key%22%3A%22301719366592208%22%2C%22locale%22%3A%22en_US%22%2C%22sdk%22%3A%22joey%22%2C%22ref%22%3A%22.UKWNYwbFB-8.like%22%2C%22channel_url%22%3A%22https%3A%2F%2Fs-static.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D17%23cb%3Df13bb8c95%26origin%3Dhttps%253A%252F%252Fns2383.hostgator.com%252Ff2bf9f920%26domain%3Dns2383.hostgator.com%26relation%3Dparent.parent%22%2C%22href%22%3A%22https%3A%2F%2Fwww.facebook.com%2Fpages%2FDummy-Page-for-Testing%2F375795832160%22%2C%22node_type%22%3A%22link%22%2C%22width%22%3A%2290%22%2C%22font%22%3A%22arial%22%2C%22layout%22%3A%22button_count%22%2C%22colorscheme%22%3A%22light%22%2C%22action%22%3A%22like%22%2C%22show_faces%22%3A%22false%22%2C%22send%22%3A%22false%22%2C%22extended_social_context%22%3A%22false%22%2C%22ret%22%3A%22sentry%22%2C%22act%22%3A%22connect%22%7D
I've already read this article on SO already and followed the answer but still didn't work. Any views on this error?
PS:
I am all in all fairly new to this.
and here's the sample code I'm using:
<?php
include_once("../incs/dbcon.php");
require_once('AppInfo.php');
require_once('utils.php');
require_once('../sdk/src/facebook.php');
//This gets the signed_request from FB which checks the 'liked' status on the current page
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$app_data = isset($data["app_data"]) ? $data["app_data"] : '';
$_REQUEST["fb_page_id"] = $data["page"]["id"];
$access_admin = $data["page"]["admin"] == 1;
$has_liked = $data["page"]["liked"] == 1;
$facebook = new Facebook(array(
'appId' => AppInfo::appID(),
'secret' => AppInfo::appSecret(),
));
$user_id = $facebook->getUser();
if ($user_id) {
try {
// Fetch the viewer's basic information
$basic = $facebook->api('/me');
} catch (FacebookApiException $e) {
// If the call fails we check if we still have a user. The user will be
// cleared if the error is because of an invalid accesstoken
if (!$facebook->getUser()) {
header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
exit();
}
}
// This fetches some things that you like . 'limit=*" only returns * values.
// To see the format of the data you are retrieving, use the "Graph API
// Explorer" which is at https://developers.facebook.com/tools/explorer/
$likes = idx($facebook->api('/me/likes?limit=4'), 'data', array());
// This fetches 4 of your friends.
$friends = idx($facebook->api('/me/friends?limit=4'), 'data', array());
// And this returns 16 of your photos.
$photos = idx($facebook->api('/me/photos?limit=16'), 'data', array());
// Here is an example of a FQL call that fetches all of your friends that are
// using this app
$app_using_friends = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'
));
}
// Fetch the basic info of the app that they are using
$app_info = $facebook->api('/'. AppInfo::appID());
$app_name = idx($app_info, 'name', '');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:fb="http://ogp.me/ns/fb#">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo he($app_name); ?></title>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# bpapptestbpapptest: http://ogp.me/ns/fb/bpapptestbpapptest#">
<meta property="fb:app_id" content="301719366592208" />
<meta property="og:type" content="bpapptestbpapptest:video" />
<meta property="og:url" content="Put your own URL to the object here" />
<meta property="og:title" content="Sample Video" />
<meta property="og:image" content="https://ns2383.hostgator.com/~caryucla/bpcontest/Images/BPIcon.png" />
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object#">
<meta property="fb:app_id" content="301719366592208" />
<meta property="og:type" content="object" />
<meta property="og:url" content="Put your own URL to the object here" />
<meta property="og:title" content="Sample Object" />
<meta property="og:image" content="https://ns2383.hostgator.com/~caryucla/bpcontest/Images/BPIcon.png" />
<link href="https://ns2383.hostgator.com/~caryucla/bpcontest/CSS/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function logResponse(response) {
if (console && console.log) {
console.log('The response was', response);
}
}
$(function(){
// Set up so we handle click on the buttons
$('#postToWall').click(function() {
FB.ui(
{
method : 'feed',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendToFriends').click(function() {
FB.ui(
{
method : 'send',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendRequest').click(function() {
FB.ui(
{
method : 'apprequests',
message : $(this).attr('data-message')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
});
</script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '301719366592208', // App ID
channelUrl : ' https://ns2383.hostgator.com/~caryucla/bpcontest/HTML/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true,
xfbml : true // parse XFBML
});
// Listen to the auth.login which will be called when the user logs in using the Login button
//FB.Event.subscribe('auth.login', function(response) {
// We want to reload the page now so PHP can read the cookie that the
// Javascript SDK sat. But we don't want to use
// window.location.reload() because if this is in a canvas there was a
// post made to this page and a reload will trigger a message to the
// user asking if they want to send data again.
//window.location = window.location;});
//FB.Canvas.setAutoGrow();
FB.Event.subscribe('auth.authResponseChange', function(response) {
alert('The status of the session is: ' + response.status);});
};
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=301719366592208";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<link rel="stylesheet" href="https://ns2383.hostgator.com/~caryucla/bpcontest/CSS/jquery-ui.css" /><!--http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css-->
<script src="https://ns2383.hostgator.com/~caryucla/bpcontest/javascript/jquery-1.8.2.js"></script><!--http://code.jquery.com/jquery-1.8.2.js-->
<script src="https://ns2383.hostgator.com/~caryucla/bpcontest/javascript/jquery-ui.js"></script><!--http://code.jquery.com/ui/1.9.1/jquery-ui.js-->
<script src="https://ns2383.hostgator.com/~caryucla/bpcontest/javascript/jquery.bgiframe-2.1.2.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
FB.Event.subscribe('edge.create',
function(response) {
$(function onclick() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:250,
modal: true,
buttons: {
"Register?": function() {
window.location="https://ns2383.hostgator.com/~caryucla/bpcontest/HTML/RegForm.php";
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
}
);
</script>
</head>
<body>
<div id="Content">
<div id="header">
<div id="LogoDiv">
<img id="logo" src=" https://ns2383.hostgator.com/~caryucla/bpcontest/Images/Bp logo.png"></div><!--end of LogoDiv-->
<div id="LogoTextDiv">
<p id="LogoText">Fashion & Compassion Contest</p></div><!--end of LogoTextDiv-->
</div><!--end of header-->
<div id="DummyRow1"></div><!--end of DummyRow-->
<div id="BGForm">
<div id="Home">
<div id="Welcome">
<h1 id="WelcomeText">Welcome to Banana Peel's Fashion and Compassion Contest App!</h1>
</div><!--end of Welcome-->
<div id="HomeMechanics">
<h2>Contest Mechanics:</h2>
<div id="FBLogIn" class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1" autologoutlink="true" onlogin="OnRequestPermission();"></div><!--end of FBLogIn div-->
<p id="Mec">To join the contest, Participants must first Log In through Facebook and LIKE Banana Peel's Facebook Fan Page. After liking the page you will be able to click the registration link button.</p>
<div id="LikeBox">
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like" fb:like:layout="button_count" addthis:url="https://www.facebook.com/pages/Dummy-Page-for-Testing/375795832160" addthis:title="Banana Peel Page" onclick="onclick()"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_pinterest_pinit"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<div id="dialog-confirm">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin: 0 7px 20px 0;"></span>Thank you for liking our page!</p>
</div><!--end of dialog-confirm div--><!--end of class addthis_toolbox addthis_default_style-->
<script type="text/javascript" src="https://ns2383.hostgator.com/~caryucla/bpcontest/javascript/addthis_widget.js"></script>
</div><!--end of LikeBoxhttp://s7.addthis.com/js/300/addthis_widget.js#pubid=xa-50a0584951afe01c-->
</div><!--end of HomeMechanics-->
<div id="ContestantsBG">
<img src="https://ns2383.hostgator.com/~caryucla/bpcontest/Images/BPpic.jpg"/>
</div><!--end of ContestantBG-->
<div id="GalleryButton">
<a id="BackLink" href="../HTML/ContestantGallery.php"><input type="button" value="VIEW GALLERY OF CONTESTANTS"></a>
</div><!--end of GalleryButton-->
</div><!--end of Home-->
</div><!--end of BGForm-->
</div><!--end of Content-->
</body>
</html>

This message is what Facebook use to stop Like-jacking and prevent spam. It can also appear if the Like button has been added to a website / domain for the first time. Give it time and the message will disappear once Facebook is satisfied that your site isn't doing any of the above things.

Related

Facebook dialog feed, doesnt post to friend wall. JavaScript sdk

Im trying to post to a facebook friend wall after a friend is selected.
Im using friend's selector from https://codersgrave.com/
I have this code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Friend Selector Basic Example - Coders' Grave</title>
<!-- Add Facebook Friend Selector CSS -->
<link type="text/css" href="friend-selector/jquery.friend.selector-1.2.1.css" rel="stylesheet" />
<!-- Add jQuery library -->
<script type="text/javascript" src="js/libs/jquery-1.6.2.min.js"></script>
<!-- Add Facebook Friend Selector JS -->
<script type="text/javascript" src="friend-selector/jquery.friend.selector-1.2.1.js"></script>
<!-- Friend Selector Integration -->
<script type="text/javascript">
jQuery(document).ready(function($) {
var id = 0;
$(".bt-fs-dialog").fSelector({
max: 1,
onSubmit: function(response){
id = response[0];
alert(id);
FB.ui({
method: 'feed',
link: 'https://developers.facebook.com/docs/dialogs/',
caption: 'My text',
to: id,
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
});
}
});
});
</script>
</head>
<body>
<!-- Facebook Integration -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '1399631740271365', // Facebook Application ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.authResponse) {
$(".connect").attr("class", "logout").text("Logout");
$(".fs-dialog-container").show();
$(".logout").click(function(){
FB.logout(function(response) {
location.reload();
});
});
} else {
}
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
jQuery(document).ready(function($){
$(".connect").click(function(){
FB.login(function(response) {
if (response.authResponse) {
location.reload();
} else {
// User cancelled login or did not fully authorize
}
}, {scope: 'user_groups'});
});
});
</script>
Connect
<br />
Click here
</body>
</html>
I can select the friend, the dialog box shows ok, and finally my alert showing: "'Post was published.'" also displays, but still if i enter to my friend's wall, i can't see my post.
I have also tried posting to my own wall, and it's the same.
Any ideas?
Thanks

OAuthException when posting story with Facebook Open Graph

I´m having a problem posting my first story on Facebook with the Open Graph.
I started a site at OrionHub. This is my code:
I have already created an action and an object.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta property="fb:app_id" content="APP_ID" />
<meta property="og:type" content="pruebablackbear:app" />
<meta property="og:url" content="http://facebookapp.orionhub.org:8080/index.html" />
<meta property="og:title" content="Sample app" />
<meta property="og:image" content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>My Facebook App</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '124306291113571', // App ID from the app dashboard
channelUrl : '//facebookapp.orionhub.org:8080/index.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<h2 class="saludo">HELLO </div>
<button class = 'loginButton'> Press me to Login </button>
<button class = 'publiSH'> Publicar una historia </button>
<script src="main.js"></script>
</body>
</html>
main.js
$('.loginButton').click(function(){
// FACEBOOK LOGIN
FB.login(function(response) {
// GETTING FACEBOOK DATA
FB.api('/me', function(response) {
// stuff you want to happen after getting data goes here
// alert(response.name);
// console.log(response);
$(".saludo").append(response.name);
}); //FB.api
// END - FACEBOOK DATA
},{scope: 'publish_actions'}); //FB.login
// END - FACEBOOK LOGIN
}); //click
$('.publish').click(function(){
FB.getLoginStatus(
function(response){
// alert(response.status);
if(response.status=="connected"){
//stuff to happen after click goes here. E.g.
FB.api(
'me/objects/pruebablackbear:app',
'post',
{
app:"http://facebookapp.orionhub.org:8080/index.html",
privacy:{'value': 'SELF'}
},
function(response) {
// handle the response
if (!response || response.error) {
alert(JSON.stringify(response.error));
alert('Error Occurred ' + response.responseText + " " + response.error.responseText);
} else {
alert('Published: ' + response.id);
}
}
);
window.open('http://www.google.com','mywindow','width=400,height=200');
}else{
alert("Please Login");
}
}
);
}); //click
I can log in correctly, but when I try to publish a story I get this message:
{"message":"(#100) The parameter object is required","type":"OAuthException","code":100}
What's wrong?
You have used app as property name in the JavaScript object that you pass to FB.api:
FB.api(
'me/objects/pruebablackbear:app',
'post',
{
app:"http://facebookapp.orionhub.org:8080/index.html",
privacy:{'value': 'SELF'}
},
but that seems to be the name of your action - the parameter must use the same name that the object you are performing the action upon is called.
So if your object was named banana, it would be:
FB.api(
'me/objects/pruebablackbear:app',
'post',
{
banana:"http://facebookapp.orionhub.org:8080/index.html",
privacy:{'value': 'SELF'}
},
Edit: I think that’s what it should look like:
FB.api(
'me/pruebablackbear:crear',
'post',
{
app: 'http://facebookapp.orionhub.org:8080/index.html',
privacy: {value: 'SELF'}
},

Facebook open graph GraphMethodException Unsupported post request

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# music: http://ogp.me/ns/fb/music#">
<meta property="fb:app_id" content="###########" />
<meta property="og:type" content="music.song" />
<meta property="og:url" content="http://mymediaupload.com/fbindex1.php" />
<meta property="og:locale" content="en_US" />
<meta property="og:title" content="MyMediaUpload" />
<meta property="og:description" content="MMU" />
<meta property="og:image" content="http://www.mymediaupload.com/v4/img/ErrorBG.png" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1" scope="publish_actions"></div>
<input type="button" value="Read" class="openGraphButton" action="song" page="http://mymediaupload.com/fbindex1.php" />
<script type="text/javascript">
$(document).ready(function()
{
$('.openGraphButton').click(function(){
var action = $(this).attr('action');
var page = $(this).attr('page');
postAction( action, 'article', page);
});
});
function postAction( action, object_type, object_url ){
FB.api('/me/music.' + action + '?' + object_type + '=' + object_url, 'post', function(response){
var msg = 'Error occured';
if (!response || response.error)
{
if (response.error) {
msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
}
alert(msg);
}
else
{
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '###########', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</body>
</html>
I have used facebooks own actions.. I have searched and searched! I fixed all my errors apart from this last one, i get the error:
Error occured
Type: GraphMethodException
Message: Unsupported post request.
Please help! I can't find an answer!

Facebook opengraph form error

I am trying out the facebook opengraph cookie recipe tutorial and I am following all the instructions, but every time I hit the cook form on it, it still says error. I am using php and using a heroku server. Here is my code:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# tommytechcook:
http://ogp.me/ns/apps/tommytechcook#">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="145722645553824" />
<meta property="og:type" content="tommytechcook:recipe" />
<meta property="og:title" content="Stuffed Cookies" />
<meta property="og:image" content="http://fbwerks.com:8000/zhen/cookie.jpg" />
<meta property="og:description" content="The Turducken of Cookies" />
<meta property="og:url" content="https://simple-journey-2635.herokuapp.com/cook.html">
<script type="text/javascript">
function postCook()
{
FB.api(
'/me/tommytechcook:cook?recipe=https://simple-journey-2635.herokuapp.com/cook.html',
'post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Cook was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '145722645553824', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<fb:add-to-timeline></fb:add-to-timeline>
<h3>Stuffed Cookies</h3>
<p>
<img title="Stuffed Cookies"
src="http://fbwerks.com:8000/zhen/cookie.jpg"
width="550"/>
</p>
<br>
<form>
<input type="button" value="Cook" onclick="postCook()" />
</form>
</body>
</html>
alert(response.error);
will return "Object Object".
Use instead:
alert(JSON.stringify(response.error));
user1304503, I'm interested in finding out how you got around this problem - I'm having a hard time setting up a test app myself (one that posts to a user's news feed)
WoolyG
My guess is that you're not logged in. I don't see FB.login() anywhere.
What's the error message?
Change alert('Error occured'); to alert(response.error); to see the error message.

Facebook Reveal Without PHP

I found some code on here for NON-PHP Revealing HTML when the Like button is clicked however, not working for me. The code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
body {
width:520px;
margin:0; padding:0; border:0;
font-family: verdana;
background:url(repeat.png) repeat;
margin-bottom:10px;
}
p, h1 {width:450px; margin-left:50px; color:#FFF;}
p {font-size:11px;}
#container_notlike, #container_like {
display:none
}
</style>
<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
FB.login(function (response) {
if (response.session) {
var user_id = response.session.uid;
var page_id = "167544069999229";
var fql_query = "SELECT uid FROM page_fan WHERE page_id = " + page_id + "and uid=" + user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function (rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
$("#container_like").show();
//here you could also do some ajax and get the content for a "liker" instead of simply showing a hidden div in the page.
} else {
$("#container_notlike").show();
//and here you could get the content for a non liker in ajax...
}
});
} else {
// user is not logged in
}
});
});
</script>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId: '270349276366373',
status: true,
cookie: true,
xfbml: true
});
</script>
<div id="container_notlike">
YOU DONT LIKE
</div>
<div id="container_like">
YOU LIKE
</div>
</body>
</html>
I have changed the APPID and PageID as necessary but not working and it keeps trying to bring up a pop up window.
It will eventually contain dynamic content in vb.net aspx file, so PHP isnt available to me.
Any ideas, can it be done server side through a SOAP or REST request?
you have to wait until the script is loaded and the FB va is init, try this flow...
if you have problem with login
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// fired when script is loaded
window.fbAsyncInit = function() {
FB.init({
appId : '', // App ID
channelUrl : '', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
//do some stuff here (Login)
};
// Load the SDK Asynchronously
(function(d){
var js;
var id = 'facebook-jssdk'
var ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>