English 中文(简体)
• 在数据库中增加Facebook的预报数据——获得邮资,电子邮件
原标题:Can t add Facebook API data to Database - won t $.post name, email

我在数小时的时间里一直在为之奋斗......

我的网站上有“Facethton”和“Im”,试图将经认证的用户数据输入一个数据库。 视像可能是一种新鲜的视像,会发现我的错误,因此,我已经知道。

<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
    FB.init({
        appId   :  MY APP ID ,
        oauth   : true,
        status  : true, // check login status
        cookie  : true, // enable cookies to allow the server to access the session
        xfbml   : true // parse XFBML
    });

  };

function fb_login(){
    FB.login(function(response) {

        if (response.authResponse) {
            console.log( Welcome!  Fetching your information....  );
            //console.log(response); // dump complete info
            access_token = response.authResponse.accessToken; //get access token
            user_id = response.authResponse.userID; //get FB UID

            FB.api( /me , function(response) {
                 $.post("addtodb.php", {name: response.name})
            });

            window.location.href = "next.php"; //redirect once authorized

            FB.api( /me/devlogintest:join ,  action , 
            { object :  http://www.mysite.com  });

        } else {
            //user hit cancel button
            console.log( User cancelled login or did not fully authorize. );

        }
    }, {
        scope:  email,publish_actions 
    }
    );
}
(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);
}());
</script>

添加。 php script...

<?php

include( config.php );
$fbname = $_POST[ name ];

if(!empty($_POST)){ //won t submit blanks if no data

// Make a MySQL Connection
mysql_connect($Host,$Username,$Password) or die(mysql_error());
mysql_select_db($Database) or die(mysql_error());

// Insert rows
mysql_query("INSERT INTO fbusers 
(name) VALUES( $fbname ) ") 
or die(mysql_error());  
}
?>

我看不出用户的名字去张贴并添加数据库。 如果我用警钟发出警报,它确实掩盖了正确的信息。 当我能够核对错误时,在网址文字方面似乎也没有任何错误。

频率呼吁被列入头盔。

我失踪了什么?

问题回答

您的法典中的一个主要问题是,在作为同义编码之后,即使用再定向......FB.api$.post,以简便的方式开展工作,从而转至next.php/code>。

如以下评论所述:$results = mysql_query ($query) or die("Error: “. mysql_error();将产生未定义的$query/code>的警告,并造成空洞 que。 如果打上文字(可能的话)的话,你就应当看到对标识的警告(因为错误报告使得这种警告成为可能)。

在<代码>美元<后的备注功能内移转代码。 因此,它要等到您的发言稿收到数据为止。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...