Reputation: 37
I've been using the PHP-SDK for wall posts, but I am converting to the Javascript SDK for the familiar popup and callbacks. I've managed to get it working when the app URL points to the Javascript, but I need to be able to call it from an AS3 game.
I'm not sure if it is an authentication issue or an issue calling it. I tried using a console.log and I never saw it in Firebug.
Here is my post code.
<?php
include 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '165114483572553',
'secret' => 'c65114e7dbc8b1eeed9f6535c1aee888', ));
$user = $facebook->getUser();
$message = $_POST['message'];
$url = $_POST['link'];
$picture = $_POST['picture'];
$name = $_POST['name'];
$description = $_POST['description'];
$userID = $_POST['id'];
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<script>
console.log("script");
FB.init({appId: "APP-ID", status: true, cookie: true});
var caption = "Come Play with Me!";
var description = 'Sup.';
var name = 'TaDa';
var picture = 'http://fbrell.com/f8.jpg';
var userID = 'USER-ID';
var message = 'hello';
var url = 'http://apps.facebook.com/zombie-kiri';
postToFeed();
function postToFeed() {
console.log("hello post");
// calling the API ...
var obj = {
method: 'feed',
to: userID,
message: message,
link: url,
picture: picture,
name: name,
caption: caption,
description: description,
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
</body>
</html>
The PHP Authentication at the top was a test as well as the POST variables. With or without the PHP this doesn't run.
Potentially I could use the Graph calls to do this as well, but I want to have access to the Invite Friend menus included in the JS SDK.
Upvotes: 0
Views: 842
Reputation: 6209
I'm pretty sure you need to invoke FB.getLoginStatus() (and await the callback) before you can start popping Dialogues to the user.
Upvotes: 1