Hi, hope someone can help with this. I had a birthday reminder app that has the usual permissions, including offline access, etc.
The application requires a daily cron job that will run on my server. When I run the cron file, you get the error below
Fatal error: OAuthException failed: Invalid OAuth access token signature. thrown at blah / base_facebook.php on line 1140;
Is there a common cause of the error, am I doing something wrong that stands out, and should I show more code in order to get help from people?
The following are the lines leading to the error. My code ends on line 1140;
<?php $name = 'api'; if (isset($READ_ONLY_CALLS[strtolower($method)])) { $name = 'api_read'; } else if (strtolower($method) == 'video.upload') { $name = 'api_video'; } return self::getUrl($name, 'restserver.php'); } protected function getUrl($name, $path='', $params=array()) { $url = self::$DOMAIN_MAP[$name]; if ($path) { if ($path[0] === '/') { $path = substr($path, 1); } $url .= $path; } if ($params) { $url .= '?' . http_build_query($params, null, '&'); } return $url; } protected function getCurrentUrl() { if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http://'; } $currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $parts = parse_url($currentUrl); $query = ''; if (!empty($parts['query'])) { // drop known fb params $params = explode('&', $parts['query']); $retained_params = array(); foreach ($params as $param) { if ($this->shouldRetainParam($param)) { $retained_params[] = $param; } } if (!empty($retained_params)) { $query = '?'.implode($retained_params, '&'); } } // use port if non default $port = isset($parts['port']) && (($protocol === 'http://' && $parts['port'] !== 80) || ($protocol === 'https://' && $parts['port'] !== 443)) ? ':' . $parts['port'] : ''; // rebuild return $protocol . $parts['host'] . $port . $parts['path'] . $query; } protected function shouldRetainParam($param) { foreach (self::$DROP_QUERY_PARAMS as $drop_query_param) { if (strpos($param, $drop_query_param.'=') === 0) { return false; } } return true; } protected function throwAPIException($result) { $e = new FacebookApiException($result); ?>
cron.php
<?php require_once("src/facebook.php"); include("custom.php"); set_time_limit(0); $config = array(); $config['array'] = $appID; $config['secret'] = $appSecret; $facebook = new Facebook($config); $day = abs(date("j")); $month = abs(date("n")); $result = mysql_query("SELECT uid, uid2, name2 FROM birthdays WHERE birthmonth = '$month' AND birthday = '$day'"); while(($row = mysql_fetch_assoc($result)) && mysql_num_rows($result)) { $link = $hostURL.'post.php?uid='.$row['uid'].'&uid2='.$row['uid2']; $facebook->api('/'.$row['uid'].'/feed', 'POST', array( 'link' => $link, 'from' => '299185790135651', 'picture' => $hostURL.'image.php?id='.$row['uid2'], 'name' => 'Send Cake', 'message' => 'It\ '.$row['name2'].'\ birthday today! Send them a virtual cake!', 'caption' => 'Sponsored by Intercake Ltd' )); } ?>
also ... what is 'from' => '299185790135651' ,?
I want to check that my developer put the correct number here. Thanks