Please try the following as your new facebook_authorization.php file and let me know how it goes. :)
PHP Code:
<?php
/**
* facebook_authorization.php
*
* @Toni's AutoFacebook Fix
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @copyright Portions Copyright Facebook
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: facebook_authorization.php Toni Scraparoni 2012-03-30 $
*/
//edit with your info
$app_id = '1234567890987654321'; //given when you created app
$app_secret = 'abcdefghijklmnopqrstuvwxyz12345'; //given when you created app
$app_location = 'http://your-website.com/facebook/facebook_authorization.php'; //full url to location of this file
/////////////////////////////////////////////////////////////////////
// Don't Edit Below This Line
/////////////////////////////////////////////////////////////////////
// get app access token
$app_url = 'https://graph.facebook.com/oauth/access_token';
$params = array('grant_type' => 'client_credentials',
'client_id' => $app_id,
'client_secret' => $app_secret);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $app_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$at_result = curl_exec($ch);
curl_close($ch);
$at_result = explode("=", $at_result);
$access_token = $at_result[1];
// get user access token
// removed offline access per FB note about deprecating this in May 2012
$scope = "read_stream,publish_stream,manage_pages";
if (!isset($_GET["code"])){
header("location: https://graph.facebook.com/oauth/authorize?client_id=".$app_id."&redirect_uri=".$app_location."&scope=".$scope);
}
elseif (!isset($_GET["access_token"])){
$code = $_GET["code"];
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&redirect_uri=".$app_location."&client_secret=".$app_secret."&code=".$code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ua_result = curl_exec($ch);
curl_close($ch);
$ua_result = explode("=", $ua_result);
$ua_token = $ua_result[1];
$append = '&expires';
$alength = strlen($append);
$apos = strrpos($ua_token, '&expires');
$replace = "";
$uaccess_token = substr_replace($ua_token, $replace, $apos, $alength);
}
// get page ID
$page_url = 'https://graph.facebook.com/me?access_token='.$uaccess_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $page_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page_result = curl_exec($ch);
curl_close($ch);
$page_result = explode('"', $page_result);
$page_id = $page_result[3];
echo "<h1 style='color: #009900'>Success!</h1><br /><br />
<span style='padding-right: 20px;'>Your Application access token is: </span>
<span style='color: #009900; font-weight: bold'>". $access_token."</span><br /><br /><br /><br />
<span style='padding-right: 20px;'>Your User access token is: </span>
<span style='color: #009900; font-weight: bold'>". $uaccess_token."</span><br /><br /><br /><br />
<span style='padding-right: 20px;'>Your Page ID is: </span>
<span style='color: #009900; font-weight: bold'>". $page_id."</span><br /><br /><br /><br /><br /><br />";
echo "You will only need two out of the three above: Page ID, and your choice of the Application access token <b><u>or</u></b> the User access token.<br /><br /><br />If I understood correctly, user access tokens will expire at some point, while application access does not. There seem to be other differences as well, so I thought it best to provide both and let you choose.<br /><br /><br />Copy and paste your code into the designated spots in admin/includes/modules/update_product.php.<br />
<br /><br />Remember to delete this file from your server when you are finished. You can always upload and run it again if you need to obtain the data or make any changes.<br /><br /><br />
<em>Note: if you see a period (or any other punctuation) at the end of your access tokens, please copy and paste that as well, as it is part of the token. If it's in green, it goes with you. :)</em>";
?>
Bookmarks