many game apps I have on Facebook are being deleted, and when I ask the facebook support, the answer is always the same:
"We've disabled your app for creating a negative experience on Facebook in Violation of our policies (https://developers.facebook.com/policy). Common violations include Sending Out excessive requests or notifications, auto-posting without consent, and pre-filling content.
We regret That We will not be able to restore your app. This is the final decision. "
I suspect it is something related to "activity log" because whenever the user enters the application, the message in the activity log: "The user playing game ...", or the user "the user is playing"
The code in facebook I am using is this:
<?php
// appsource
require_once 'facebook.php';
require_once 'appinclude.php';
if (isset($_GET['code'])){
header("Location: " . $canvasPage);
exit;
}
$fb = new Facebook(array(
'appId' => $appid,
'secret' => $appsecret,
'cookie' => true
));
$me = null;
$user = $fb->getUser();
if($user) {
try {
$me = $fb->api('/me');
} catch(FacebookApiException $e) {
error_log($e);
}
}
if($me) {}
else {
$loginUrl = $fb->getLoginUrl(array(
'scope' => ''
));
echo "
<script type='text/javascript'>
window.top.location.href = '$loginUrl';
</script>
";
exit;
}
if(isset($_GET['signed_request'])) {
$fb_args = "signed_request=" . $_REQUEST['signed_request'];
}
include 'spinc.php';
function ae_detect_ie(){
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;}
?>
<html xmlns:fb="//ogp.me/ns/fb#">
<head>
<meta charset="utf-8">
<meta content='IE=edge' http-equiv='X-UA-Compatible' />
<link rel="stylesheet" type="text/css" href="/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="imagetoolbar" content="no">
<title>TITLE APP</title>
</script>
</head>
<body><div id="all">
<h1>NAME APP</h1>
<!--Resize Iframe-->
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '<?=$appid?>',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true // enable OAuth 2.0
});
FB.Canvas.setAutoGrow();
</script>
<!-- End Resize Iframe-->
<div id="likebutton"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fapps.facebook.com%2FXXXAPPNAMEXXX%2F&send=false&layout=standard&width=450&show_faces=false&action=like&colorscheme=light&font&height=35&appId=XXXAPPIDXXX" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe> </div>
<center><object width="750" height="500">
<param value="XXXXXXX.swf" name="movie">
<param name="allownetworking" value="internal" />
<param name="bgcolor" value="#336699" />
<param NAME="wmode" value="opaque">
<param NAME="quality" value="high">
<param name="salign" value="c">
<param name="scale" value="exactfit">
<embed salign="c" scale="exactfit" width="750" height="550" src="XXXXXXXXXXX.swf" bgcolor="#336699" allownetworking="internal" wmode="opaque" allowfullscreen="true" quality="high">
</embed>
</object>
</center>
</div>
</body></html>
Is there something wrong with my code?
Related
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.
I have tried to follow the sample tutorial of facebook : developers.facebook.com/docs/opengraph/tutorial/#debug
But after i made it and clicked on cook button , it is showing "Error Occured".
You can see the app here : http://www.akashbc.com/facebookapp/index.html
The following is the page source for the app:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/abcrecipelist#">
<meta property="fb:app_id" content="258611890922127" />
<meta property="og:type" content="abcrecipelist:recipe" />
<meta property="og:title" content="Oreo Stuffed Cookies" />
<meta property="og:image" content="http://1.bp.blogspot.com/-92sA7pC51pg/T9CKdHHeDzI/AAAAAAAACbg/MRq4PR2P5QQ/s1600/jQuery_Cookies.jpg" />
<meta property="og:description" content="The Turducken of Cookies" />
<meta property="og:url" content="http://www.akashbc.com/facebookapp/index.html">
<script type="text/javascript">
function postCook()
{
FB.api('/me/abcrecipelist:cook&recipe=http://www.akashbc.com/facebookapp/index.html','post', function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'258611890922127', cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<fb:add-to-timeline></fb:add-to-timeline>>
<h3>
<font size="30" face="verdana" color="grey">Stuffed Cookies
</font>
</h3>
<p>
<img title="Oreo Stuffed Cookies" src="http://1.bp.blogspot.com/-92sA7pC51pg/T9CKdHHeDzI/AAAAAAAACbg/MRq4PR2P5QQ/s1600/jQuery_Cookies.jpg" width="550"/><br />
</p>
<form>
<input type="button" value="Cook" onclick="postCook()" />
</form>
<fb:activity actions="YOUR_NAMESPACE:cook"></fb:activity>
</body>
</html>
Also here is the screenshot from basic settings of the app :
Please tell me whats wrong..
Thanks in advance :)
Your API call is incorrect:
FB.api('/me/abcrecipelist:cook&recipe=http://www.akashbc.com/facebookapp/index.html' ...
Should be
FB.api('/me/abcrecipelist:cook?recipe=http://www.akashbc.com/facebookapp/index.html' ...
I.e. The & should be a ?.
Please someone help me. I trying this almost 1 month ... i want to retrieve the message and data. Im using the latest FB API, I tried my best I couldn't find whats wrong on it.Also I cant retreive user_id .. Do I need do anything on call back function?
App url : https://apps.facebook.com/greetingz/
this is my whole code
<?php
session_start();
if(!empty($_REQUEST['request_ids'])) {
require_once('src/facebook.php');
$config = array();
$config["appId"] = "XXXXXXXX";
$config["secret"] = "XXXXXXXXXXXX";
$config["fileUpload"] = false; // optional
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => $config["appId"],
'secret' => $config["secret"],
'cookie' => true,
));
$user_id= $facebook->getUser();
if($user_id){
try {
$app_token = $facebook->getAccessToken();
$requests = explode(',',$_REQUEST['request_ids']);
foreach($requests as $request_id) {
$data = $facebook -> api('/'.$user_id.'/apprequests?'.$app_token);
//you will delete the request here
$delete_url = "https://graph.facebook.com/".$request_id."_".$user_id."?".$app_token."&method=delete";
$result = file_get_contents($delete_url);
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}else{
?>
<script>
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=XXXXXXXXXX';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/greetingz/');
oauth_url += '&scope=user_birthday,user_events'
window.top.location = oauth_url;
</script>
<?php
};
}
else{
?>
<!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" />
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script src="js/jquery-1.6.2.min.js" type="text/javascript" ></script>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<title>Greetings</title>
</head>
<body>
<div align="center">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="664" height="626">
<param name="movie" value="flash/Candle_jey.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don't want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flash/Candle_jey.swf" width="664" height="626">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<div class="main">
<div style="margin-left:300px; width:540px; margin:auto;">
<table>
<tr>
<td>
<span style="font-size:18px;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#603;">Greeting :</span>
</td>
<td>
<textarea type="text" name="message" id="msg" style="height:40px; width:350px;" ></textarea>
</td>
<td>
<input type="submit" value="Send" id="one" style="color:#CCC; background-color:#603; border:none; width:80px; height:40px;"
onclick="sendRequestViaMultiFriendSelector(); return false;"></span>
</td>
</tr>
</table>
</div>
<script>
FB.init({
appId : 'XXXXXXXXXXX',
status : true,
cookie : true,
frictionlessRequests: true,
oauth: true
});
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: $("#msg").val(),
},function getMultipleRequests(requestIds) {
FB.api('', {"ids": requestIds }, function(response) {
console.log(response);
});
}, requestCallback);
}
function requestCallback(response) {
// Handle callback here
//var requestID = FB.api("/requestID", callback);
alert("Post was published.");
}
</script>
<div id="fb">
</div>
<?php }?>
</div>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>
Buddy read this in detail, it will solve your problem, you need to parse signed_request, in signed_request you get the user_id, you can get signed request like this authResponse.signed_request
Alternatively you can use below Facebook graph api method in place of this line "$user_id= $facebook->getUser();" in your code.
FB.login(function(loginResponse) {
if (loginResponse.authResponse) {
var userId = loginResponse.authResponse.userID;
// Work with userId here
var signed_request = loginResponse.authResponse.signedRequest;
//Work with signed request here
}
else {
//User cancelled login or did not fully authorize
}
});
i used this tutorial https://developers.facebook.com/docs/opengraph/tutorial/ to make my first App but i want to use php variable for my og:title like this <meta property="og:title" content="<?php echo $title; ?>" /> . This php variable is changing constantly every time the page loads but when I post my action in the facebook appears with the old title!
Here's the code:
<?php
$title = ' Hello world';
// <---- This php variable is changing every time
the page loads but the title is not being recognised
?>
<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# fitnessgod: http://ogp.me/ns/fb/fitnessgod#">
<meta property="og:locale" content="en_US" />
<meta property="fb:app_id" content="My app Id" />
<meta property="og:type" content="fitnessgod:news" />
<meta property="og:url" content="https://www.fitness-god.com/share-facebook.php" />
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:description" content="let's do sport" />
<meta property="og:image" content="https://www.fitness-god.com/images/sport dinamic.png" />
<script type="text/javascript">
function postCook()
{
FB.api('/me/fitnessgod:share' +
'?news=https://www.fitness-god.com/share-facebook.php','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'My App id', cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<fb:add-to-timeline></fb:add-to-timeline>
<h3>
<font size="30" face="verdana" color="grey">
Stuffed Cookies
</font>
</h3>
<p>
<img title="Sports News"
src="https://www.fitness-god.com/images/sport dinamic.png"
width="550"/><br />
</p>
<form>
<input type="button" value="Share news" onClick="postCook()" />
</form>
<fb:activity actions="fitnessgod:share"></fb:activity>
</body>
</html>
You need to correct the meta tags definition. Use attribute name, not property:
E.g.:
<meta name="og:title" content="<?php echo $title; ?>" />
You can use the debugger to test your code:
http://developers.facebook.com/tools/debug
Also note that when you click share, the content of your page might be cached. But, the debugger, always gets the latest content.
It appears you are experiencing "freezing" of og:title that Facebook performs after a number of actions – 50 likes, shares and/or comments – were performed with that link.
One of the main reasons why Facebook does this, is to prevent many people sharing a seemingly safe link and then having the site owner replace the title with offensive content and have it display on people's timelines.
For additional information, see this link.
I'm trying to implement step two of the Recipe Box Facebook app tutorial. I have followed the instructions in step one to set up my app on Facebook and have uploaded the code pasted below to my server as per the instructions in step two of the tutorial. When I load the web page and click the add-to-timeline link I get a Facebook error stating:
Given URL is not allowed by the Application configuration.
Any insight would be greatly appreciated.
Code:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<head/>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'328617653826422', cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<fb:add-to-timeline></fb:add-to-timeline>
<h3>
<font size="30" face="verdana" color="grey">
Stuffed Cookies
</font>
</h3>
<p>
<img title="Stuffed Cookies"
src="http://example.com/cookie.jpg"
width="550"/>
</p>
</body>
</html>
In your app settings, be sure that domain you specify is the same domain as where this code lives. Also in the example code, their <head> tag looked like <head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/YOUR_NAMESPACEx#">. Also you appear to be missing the og: tags in your head section as well.
Here's the example code I just downloaded from their site, did I grab the wrong link? Or are you basing yours on old example code?
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/YOUR_NAMESPACEx#">
<meta property="fb:app_id" content="YOUR_APP_ID" />
<meta property="og:type" content="YOUR_NAMESPACE:recipe" />
<meta property="og:title" content="Oreo Stuffed Cookies" />
<meta property="og:image" content="http://YOUR_URL/cookie.jpg" />
<meta property="og:description" content="The Turducken of Cookies" />
<meta property="og:url" content="http://YOUR_URL/cookie.html">
<script type="text/javascript">
function postCook()
{
FB.api('/me/YOUR_NAMESPACE:cook&recipe=http://YOUR_URL/cookie.html','post', function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'YOUR_APP_ID', cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<fb:add-to-timeline></fb:add-to-timeline>>
<h3>
<font size="30" face="verdana" color="grey">Stuffed Cookies
</font>
</h3>
<p>
<img title="Oreo Stuffed Cookies" src="http://YOUR_URL/cookie.jpg" width="550"/><br />
</p>
<form>
<input type="button" value="Cook" onclick="postCook()" />
</form>
<fb:activity actions="YOUR_NAMESPACE:cook"></fb:activity>
</body>
</html>