php – FaceBook集成麻烦的问题

前端之家收集整理的这篇文章主要介绍了php – FaceBook集成麻烦的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 PHP进行 Android游戏,但是当我尝试将分数发布到我的Facebook墙上时,描述与另一个应用程序合并.

从这个App Daily Tools和我的实际游戏中获取的描述是Just Double It

图片如下,徽标&描述错了

描述:我的游戏说明我的应用说明.

描述是自动检测到的,而不是我写的.

这是我发布到Facebook的代码snippit

var APP_ID="*****************";

window.fbAsyncInit = initFacebook;
function initFacebook()
{
    FB.init({
        appId  : APP_ID,status : true,// check login status
        cookie : false,// enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });

    FB.getLoginStatus(onFacebookLoginStatus);
};

(function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
}());

//the login function
function facebookLogin()
{
    var loginUrl="http://www.facebook.com/dialog/oauth/?"+
    "scope=publish_stream&"+
    "client_id="+APP_ID+"&"+
    "redirect_uri="+document.location.href+"&"+
    "response_type=token";
    window.location=loginUrl;
}

function postToWallUsingFBApi()
{
    var score=atob(document.getElementById("txtscore").value);

    var data=
    {
        caption: "scores "+score,message: "I challenge you to beat my score "+score + " in Just Double It! on your    Android Phone !!!",picture: "http://www.learning-delight.com/ldapps/Game/main.png",link: 'https://play.google.com/store/apps/details?id=com.appslight.justdoubleit',}

    FB.api('/me/Feed','post',data,onPostToWallCompleted);
}

//the return function after posting to wall
function onPostToWallCompleted(response)
{
    (response)
    {
        if (response.error)
        {
            document.getElementById("txtEcho").innerHTML=response.error.message;
        }
        else
        {
            if (response.id){
                window.close();
                t = setTimeout("self.close()",500);
            }
            else if (response.post_id)
                document.getElementById("txtEcho").innerHTML="Posted as post_id responce "+response.post_id;
            else
                document.getElementById("txtEcho").innerHTML="Unknown Error";
        }
    }
}
@ DrewT的答案涵盖了问题以及解决问题的一些解决方法.另一种方法是完全控制你发布的内容,不要让facebook刮掉它.如果你看 post params你可以发送到Facebook,你会发现还有一个描述参数.
var data=
{
    caption: "scores "+score,description: "I HAVE THE POWER!!",}
原文链接:https://www.f2er.com/php/134335.html

猜你在找的PHP相关文章