From 64cbef4f0de5a40a493060261ddb96fd1e467361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Mon, 9 Apr 2012 12:07:24 +0000 Subject: [PATCH] Provide a link to Martin Farrent's instructions instead of the obsolete README text; Prevent some Notices when running on E_ALL --- facebook/README | 40 ++---------------------------- facebook/facebook.php | 57 ++++++++++++------------------------------- 2 files changed, 18 insertions(+), 79 deletions(-) diff --git a/facebook/README b/facebook/README index b68ba3da..5f74d2d4 100755 --- a/facebook/README +++ b/facebook/README @@ -1,43 +1,7 @@ Installing the Friendica/Facebook connector -1. Visit https://developers.facebook.com/apps to register an app. - a) Click "Create a new app" - b) We'd be very happy if you include "Friendica" in the application name - to increase name recognition. - c) Edit your app settings on the setup page. The Friendica icons are present - in the images directory and may be uploaded as a Facebook app icon. Use - images/friendica-16.jpg for the Icon and images/Friendica-128.jpg for the logo. - d) In the App Display name enter the name of your app (this should default to the - name you chose in part a). - e) Enter YourDomain.com in the App Domain field and hit return. - f) In "Select how your app connects with Facebook select "Website" and enter the - full URL to your Friendica install including HTTPS and a trailing slash. - -2. Enable the Facebook plugin by clicking on the icon next to it's name on the plugin - page of your admin panel. - b) return to the Facebook plugin page in your admin panel, and fill in the App-ID - and Application Secret settings you got from Facebook. - c) Click save. - d) Finally, return to the Facebook settings page, and activate real-time updates. - - i. If you for any reason prefer to use a configuration file instead of the admin panels, - Activate the plugin by including it in .htconfig.php, e.g. - - $a->config['system']['addon'] = 'plugin1,plugin2,facebook'; - - and set the following values: - $a->config['facebook']['appid'] = 'xxxxxxxxxxx'; - $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx'; - - Replace with the settings Facebook gives you. - - -3. To use the Facebook plugin, visit the "connector settings" area of your settings - page. Click "Install Facebook Connector". -4. This will ask you to login to Facebook and allow the plugin to do it's stuff. - Allow it to do so. -5. You're done. To turn it off visit the Plugin Settings page again and - 'Remove Facebook posting'. +Detailed instructions how to use this plugin can be found at +https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector Vidoes and embeds will not be posted if there is no other content. Links and images will be converted to a format suitable for the Facebook API and diff --git a/facebook/facebook.php b/facebook/facebook.php index 0c31da1f..4e886608 100644 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -1,7 +1,7 @@ * Tobias Hößl */ @@ -9,33 +9,8 @@ /** * Installing the Friendica/Facebook connector * - * 1. register an API key for your site from developer.facebook.com - * a. We'd be very happy if you include "Friendica" in the application name - * to increase name recognition. The Friendica icons are also present - * in the images directory and may be uploaded as a Facebook app icon. - * Use images/friendica-16.jpg for the Icon and images/friendica-128.jpg for the Logo. - * b. The url should be your site URL with a trailing slash. - * Friendica is a software application and does not require a Privacy Policy - * or Terms of Service, though your installation of it might. Facebook may require - * that you provide a Privacy Policy, which we find ironic. - * c. Set the following values in your .htconfig.php file - * $a->config['facebook']['appid'] = 'xxxxxxxxxxx'; - * $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx'; - * Replace with the settings Facebook gives you. - * d. Navigate to Set Web->Site URL & Domain -> Website Settings. Set - * Site URL to yoursubdomain.yourdomain.com. Set Site Domain to your - * yourdomain.com. - * 2. Visit the Facebook Settings section of the "Settings->Plugin Settings" page. - * and click 'Install Facebook Connector'. - * 3. Visit the Facebook Settings section of the "Settings->Plugin Settings" page. - * and click 'Install Facebook Connector'. - * 4. This will ask you to login to Facebook and grant permission to the - * plugin to do its stuff. Allow it to do so. - * 5. Optional step: If you want to use Facebook Real Time Updates (so new messages - * and new contacts are added ~1min after they are postet / added on FB), go to - * Settings -> plugins -> facebook and press the "Activate Real-Time Updates"-button. - * 6. You're done. To turn it off visit the Plugin Settings page again and - * 'Remove Facebook posting'. + * Detailed instructions how to use this plugin can be found at + * https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector * * Vidoes and embeds will not be posted if there is no other content. Links * and images will be converted to a format suitable for the Facebook API and @@ -1391,32 +1366,32 @@ function fb_consume_stream($uid,$j,$wall = false) { logger('facebook: post '.$entry->id.' from '.$from->name); - $datarray['body'] = escape_tags($entry->message); + $datarray['body'] = (x($entry, 'message') ? escape_tags($entry->message) : ''); - if($entry->name and $entry->link) + if(x($entry, 'name') and x($entry, 'link')) $datarray['body'] .= "\n\n[bookmark=".$entry->link."]".$entry->name."[/bookmark]"; - elseif ($entry->name) + elseif (x($entry, 'name')) $datarray['body'] .= "\n\n[b]" . $entry->name."[/b]"; - if($entry->caption) { - if(!$entry->name and $entry->link) + if(x($entry, 'caption')) { + if(!x($entry, 'name') and x($entry, 'link')) $datarray['body'] .= "\n\n[bookmark=".$entry->link."]".$entry->caption."[/bookmark]"; else $datarray['body'] .= "[i]" . $entry->caption."[/i]\n"; } - if(!$entry->caption and !$entry->name) { - if ($entry->link) + if(!x($entry, 'caption') and !x($entry, 'name')) { + if (x($entry, 'link')) $datarray['body'] .= "\n[url]".$entry->link."[/url]\n"; else $datarray['body'] .= "\n"; } - $quote = ""; - if($entry->description) + $quote = ''; + if(x($entry, 'description')) $quote = $entry->description; - if ($entry->properties) + if (x($entry, 'properties')) foreach ($entry->properties as $property) $quote .= "\n".$property->name.": [url=".$property->href."]".$property->text."[/url]"; @@ -1426,14 +1401,14 @@ function fb_consume_stream($uid,$j,$wall = false) { // Only import the picture when the message is no video // oembed display a picture of the video as well if ($entry->type != "video") { - if($entry->picture && $entry->link) { + if(x($entry, 'picture') && x($entry, 'link')) { $datarray['body'] .= "\n" . '[url=' . $entry->link . '][img]'.$entry->picture.'[/img][/url]'; } else { - if($entry->picture) + if(x($entry, 'picture')) $datarray['body'] .= "\n" . '[img]' . $entry->picture . '[/img]'; // if just a link, it may be a wall photo - check - if($entry->link) + if(x($entry, 'link')) $datarray['body'] .= fb_get_photo($uid,$entry->link); } }