Trying to store a Facebook access token in DB. Token always stores as the string "css"

170 views Asked by At

I cannot figure what is going on here, I make a call to Facebook and get the access token from the response, I then make a call to the database to update an entry with the access token but every time I do this "css" is what appears as the DB entry! I print the value of the token right before making the call to the DB and even right after just to make sure nothing weird is going on and I even cast the token to a String and both times the value is as expected however the DB entry is always "css". Any help here would be really appreciated. Here's the call to get the access token and the token being sent to the php file.

....
var accessToken = String(response.authResponse.accessToken);
console.log(accessToken);
window.location.href = 'http://localhost/TITLE/index.php/CLASS/FUNCTION/' + response.authResponse.userID + '/' + latitude + '/' + longitude + '/' + accessToken;
....

Here's the function (This is all done using CodeIgniter btw)

function FUNCTION($user_id = null, $latitude = null, $longitude = null, $accessToken = null)
{
    $this->load->model('MODEL');
    $this->MODEL->set_access_token($user_id, $accessToken);
    ...

Finally, here's the function

function set_access_token($uid, $access_token)
{
    $data=array(
        'user_access_token'=>$access_token
    );
    print_r($data);
    $this->db->where('user_id', $uid);
    $this->db->update('users', $data);
    print_r($data);
}

Never seen this kind of behaviour before and I can't seem to figure out what is the cause.

#   Name                            Type    Collation   Attributes  Null    Default Extra   Action
1   user_id                         int(11)         No  None    AUTO_INCREMENT
2   user_display_name               varchar(45) utf8_general_ci     Yes NULL    
3   user_password                   varchar(45) utf8_general_ci     Yes NULL    
4   usercreated_date                datetime            Yes NULL    
5   user_last_mod_date              datetime            Yes NULL
6   user_facebook_token             varchar(45) utf8_general_ci     Yes NULL    
7   user_twitter_token              varchar(45) utf8_general_ci     Yes NULL    
8   user_last_known_location_lat    varchar(256)    utf8_general_ci     Yes NULL
9   user_last_known_location_long   varchar(128)    utf8_general_ci     Yes NULL 
10  user_access_token               varchar(256)    utf8_general_ci     Yes NULL 

EDIT: So I figured out the cause but not the reason behind it. When I remove the links to my css files (below) in the header the problem goes away.

<link rel="stylesheet" href="css/jquery.mobile-1.4.5.css" type="text/css">
<link rel="stylesheet" href="css/FILENAME.css" type="text/css">

I noticed that in the console I was seeing this message:

Resource interpreted as Stylesheet but transferred with MIME type text/html: It's clearly got to do with this error but I don't know the reason behind it. The problem is solved now but I would love to understand it so if anyone could shed some light on it I'd really appreciate it.

0

There are 0 answers