我一直在使用PHP-SDK进行墙贴,但我转换为Javascript SDK,用于熟悉的弹出窗口和回调。当应用程序URL指向Javascript时,我设法让它工作,但我需要能够从AS3游戏中调用它。
我不确定这是一个身份验证问题还是一个问题。我尝试使用console.log而我从未在Firebug中看到它。
这是我的邮政编码。
<?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>
顶部的PHP身份验证是一个测试以及POST变量。无论有没有PHP,这都不会运行。
我可以使用Graph调用来执行此操作,但我希望能够访问JS SDK中包含的Invite Friend菜单。