X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=fbpost%2Ffbpost.php;h=b554453fa7d498bc7200757199dc074e0c0f545f;hb=ca9bd8b877d8ed2306bef76c93bcc6eb77ed1fd1;hp=3d28a9693a17def021bf663df1c3804e3a7e16e2;hpb=71a42a17491bad5ba582d30685f3e5defadbfc1e;p=friendica-addons.git
diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php
index 3d28a969..b554453f 100644
--- a/fbpost/fbpost.php
+++ b/fbpost/fbpost.php
@@ -69,7 +69,7 @@ function fbpost_init(&$a) {
if(strlen($nick))
$r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
- dbesc($nick)
+ dbesc($nick)
);
if(!(isset($r) && count($r)))
return;
@@ -134,16 +134,15 @@ function fbpost_post(&$a) {
$uid = local_user();
if($uid){
-
- $fb_limited = get_config('facebook','crestrict');
-
-
$value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
set_pconfig($uid,'facebook','post_by_default', $value);
$value = ((x($_POST,'mirror_posts')) ? intval($_POST['mirror_posts']) : 0);
set_pconfig($uid,'facebook','mirror_posts', $value);
+ if (!$value)
+ del_pconfig($uid,'facebook','last_created');
+
$value = ((x($_POST,'suppress_view_on_friendica')) ? intval($_POST['suppress_view_on_friendica']) : 0);
set_pconfig($uid,'facebook','suppress_view_on_friendica', $value);
@@ -155,7 +154,7 @@ function fbpost_post(&$a) {
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
if (count($result) > 0) {
set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
- set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
+ set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
}
info( t('Settings updated.') . EOL);
@@ -189,16 +188,36 @@ function fbpost_content(&$a) {
info( t('Facebook Post disabled') . EOL);
}
+ require_once("mod/settings.php");
+ settings_init($a);
+
$o = '';
+ $accounts = array();
$fb_installed = false;
if (get_pconfig(local_user(),'facebook','post')) {
$access_token = get_pconfig(local_user(),'facebook','access_token');
if ($access_token) {
- $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
+ // fetching the list of accounts to check, if facebook is working
+ // The value is needed several lines below.
+ $url = 'https://graph.facebook.com/me/accounts';
+ $s = fetch_url($url."?access_token=".$access_token, false, $redirects, 10);
if($s) {
- $j = json_decode($s);
- if (isset($j->data)) $fb_installed = true;
+ $accounts = json_decode($s);
+ if (isset($accounts->data))
+ $fb_installed = true;
+ }
+
+ // I'm not totally sure, if this above will work in every situation,
+ // So this old code will be called as well.
+ if (!$fb_installed) {
+ $url ="https://graph.facebook.com/me/feed";
+ $s = fetch_url($url."?access_token=".$access_token."&limit=1", false, $redirects, 10);
+ if($s) {
+ $j = json_decode($s);
+ if (isset($j->data))
+ $fb_installed = true;
+ }
}
}
}
@@ -229,7 +248,7 @@ function fbpost_content(&$a) {
//read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access
$o .= '' . t('Install Facebook Post connector for this account.') . '';
+ . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Install Facebook Post connector for this account.') . '';
$o .= '';
}
@@ -241,7 +260,7 @@ function fbpost_content(&$a) {
$o .= '
';
$o .= '
' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '';
+ . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '';
$o .= '
';
$o .= '';
@@ -262,9 +281,9 @@ function fbpost_content(&$a) {
$post_to_page = get_pconfig(local_user(),'facebook','post_to_page');
$page_access_token = get_pconfig(local_user(),'facebook','page_access_token');
$fb_token = get_pconfig($a->user['uid'],'facebook','access_token');
- $url = 'https://graph.facebook.com/me/accounts';
- $x = fetch_url($url."?access_token=".$fb_token);
- $accounts = json_decode($x);
+ //$url = 'https://graph.facebook.com/me/accounts';
+ //$x = fetch_url($url."?access_token=".$fb_token, false, $redirects, 10);
+ //$accounts = json_decode($x);
$o .= t("Post to page/group:")."