jquery - why am I gettin an error passing fb accessToken to PHP via ajax? -
this question related bounty question didn't enough with.having trouble sending facebook notification via ajax call php
i need pass accesstoken php via ajax. call getloginstatus in script, obtain access token response, , send include in post data ajax. it's giving me error though , don't know why. syntax problem?
fb.getloginstatus(function(response) { if (response.status === 'connected') { var accesstoken = response.authresponse.accesstoken; console.log(accesstoken); $.ajax({ url : "http:/xxxxxxio/bn/notification.php", type : 'post', data: { token: accesstoken }, success : function (result) { console.log(result); }, error : function () { alert("error sending notification"); } }); } else if (response.status === 'not_authorized') { // user logged in facebook, // has not authenticated app } else { // user isn't logged in facebook. } }); //php <?php require_once(dirname(__file__).'/php-sdk/facebook.php') ; $application_id = '14xxxxxx15107'; $application_secret = 'ce71dxxxxxxx040971a45f55a'; $fb_app_url = "http://apps.facebook.com/thebringernetwork"; $config = array(); $config['appid'] = $application_id; $config['secret'] = $application_secret; $config['cookie'] = true; $facebook = new facebook($config) or die('error here!'); $facebook = new facebook(array( 'appid' => $application_id, 'secret' => $application_secret, 'fileupload' => true )); $facebook->setaccesstoken($_post['token']); $userid = $facebook->getuser(); echo $userid; $token_url ="https://graph.facebook.com/oauth/access_token?" . "client_id=" . $application_id . "&client_secret=" . $application_secret . "&grant_type=client_credentials"; $app_token = file_get_contents($token_url); $app_token = str_replace("access_token=", "", $app_token); $data = array( 'href'=> 'https://apps.facebook.com/thebringernetwork/', 'access_token'=> $app_token, 'template'=> 'test' ); $facebook->api('/1xxxx653/notifications', 'post', $data); ?>
Comments
Post a Comment