$config['user_token'], 'client_id' => $config['app_id'], 'client_secret' => $config['app_secret'], 'redirect_uri' => 'http://rss.emkael.info/facebook.php' ]); $firstResponse = json_decode(file_get_contents($firstLink)); $secondLink = 'https://graph.facebook.com/oauth/access_token?' . http_build_query([ 'client_id' => $config['app_id'], 'code' => $firstResponse->code, 'redirect_uri' => 'http://rss.emkael.info/facebook.php' ]); print($secondLink); die(); $secondResponse = json_decode(file_get_contents($secondLink)); $config['user_token'] = $secondResponse->access_token; fwrite(STDERR, 'FB API token renewed, expires on: ' . date('Y-m-d H:i:s', strtotime('+' . $secondResponse->expires_in . ' seconds')) . PHP_EOL); file_put_contents($configFile, json_encode($config)); file_put_contents($expiryFile, date('Y-m-d', strtotime('+' . ($secondResponse->expires_in - 1440) . ' seconds'))); } ?>