From c66fb8ec9eba761da8800134cc80733e1bf7a22b Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 16 Jan 2017 23:52:38 +0100 Subject: * script to renew FB user token --- _cron/fb-user-token | 1 + bin/fb-user-token.php | 30 ++++++++++++++++++++++++++++++ bin/fb-user-token.sh | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 _cron/fb-user-token create mode 100644 bin/fb-user-token.php create mode 100755 bin/fb-user-token.sh diff --git a/_cron/fb-user-token b/_cron/fb-user-token new file mode 100644 index 0000000..b202490 --- /dev/null +++ b/_cron/fb-user-token @@ -0,0 +1 @@ +25 9 20 * * $SITEPATH/bin/fb-user-token.sh diff --git a/bin/fb-user-token.php b/bin/fb-user-token.php new file mode 100644 index 0000000..c78abfc --- /dev/null +++ b/bin/fb-user-token.php @@ -0,0 +1,30 @@ + $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' + ]); +$secondResponse = json_decode(file_get_contents($secondLink)); + +$config['user_token'] = $secondResponse->access_token; + +print json_encode($config); + +?> diff --git a/bin/fb-user-token.sh b/bin/fb-user-token.sh new file mode 100755 index 0000000..c0ad09f --- /dev/null +++ b/bin/fb-user-token.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd /srv/websites/rss.emkael.info +php bin/fb-user-token.php | json_pp > config/temp.json +mv config/temp.json config/facebook.json -- cgit v1.2.3