mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-22 19:10:15 +00:00
import images for wall photos (which facebook provides as an unnamed link and not a photo)
This commit is contained in:
parent
4daa4ab6a8
commit
b896a5c2db
2 changed files with 17 additions and 1 deletions
BIN
facebook.tgz
BIN
facebook.tgz
Binary file not shown.
|
@ -863,6 +863,21 @@ function fb_consume_all($uid) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fb_get_photo($uid,$link) {
|
||||||
|
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||||
|
if(! $access_token || (! stristr($link,'facebook.com/photo.php')))
|
||||||
|
return "\n" . '[url=' . $link . ']' . t('link') . '[/url]';
|
||||||
|
$ret = preg_match('/fbid=([0-9]*)/',$link,$match);
|
||||||
|
if($ret)
|
||||||
|
$photo_id = $match[1];
|
||||||
|
$x = fetch_url('https://graph.facebook.com/' . $photo_id . '?access_token=' . $access_token);
|
||||||
|
$j = json_decode($x);
|
||||||
|
if($j->picture)
|
||||||
|
return "\n\n" . '[url=' . $link . '][img]' . $j->picture . '[/img][/url]';
|
||||||
|
else
|
||||||
|
return "\n" . '[url=' . $link . ']' . t('link') . '[/url]';
|
||||||
|
}
|
||||||
|
|
||||||
function fb_consume_stream($uid,$j,$wall = false) {
|
function fb_consume_stream($uid,$j,$wall = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
@ -973,8 +988,9 @@ function fb_consume_stream($uid,$j,$wall = false) {
|
||||||
else {
|
else {
|
||||||
if($entry->picture)
|
if($entry->picture)
|
||||||
$datarray['body'] .= "\n\n" . '[img]' . $entry->picture . '[/img]';
|
$datarray['body'] .= "\n\n" . '[img]' . $entry->picture . '[/img]';
|
||||||
|
// if just a link, it may be a wall photo - check
|
||||||
if($entry->link)
|
if($entry->link)
|
||||||
$datarray['body'] .= "\n" . '[url=' . $entry->link . ']' . t('link') . '[/url]';
|
$datarray['body'] .= fb_get_photo($uid,$entry->link);
|
||||||
}
|
}
|
||||||
if($entry->name)
|
if($entry->name)
|
||||||
$datarray['body'] .= "\n" . $entry->name;
|
$datarray['body'] .= "\n" . $entry->name;
|
||||||
|
|
Loading…
Reference in a new issue