mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
fbpost/fbsync: Better picture support for facebook. Now the highest resolution is fetched.
This commit is contained in:
parent
1b41f6581b
commit
31ab2a3cbf
3 changed files with 36 additions and 8 deletions
|
@ -213,6 +213,8 @@ function fbsync_expire($a,$b) {
|
|||
|
||||
function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
|
||||
|
||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||
|
||||
require_once("include/oembed.php");
|
||||
|
||||
// check if it was already imported
|
||||
|
@ -365,10 +367,22 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
if (isset($media->src))
|
||||
$preview = $media->src;
|
||||
|
||||
if (isset($media->photo))
|
||||
if (isset($media->photo)) {
|
||||
if (isset($media->photo->images) AND (count($media->photo->images) > 1))
|
||||
$preview = $media->photo->images[1]->src;
|
||||
|
||||
if (isset($media->photo->fbid)) {
|
||||
logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG);
|
||||
$url = "https://graph.facebook.com/v2.0/".$media->photo->fbid."/?access_token=".$access_token;
|
||||
$feed = fetch_url($url);
|
||||
$data = json_decode($feed);
|
||||
if (isset($data->images)) {
|
||||
$preview = $data->images[0]->source;
|
||||
logger('fbsync_createpost: got fbid image '.$preview, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
|
||||
$content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue