Facebook profile info cache

guclusat

Tanınmış Üye
Süper Moderatör
Simple file edit for caching in XenForo_Helper_Facebook::getUserInfo

Very simple edit to add caching to the getUserInfo facebook function, which makes pages take ages to load when lots of facebook profiles are to be rendered.
I encountered this scenario when designing my forum's new members list: https://www.gamingmasters.org/members-list/

This is of almost zero use to XenForo itself as it stands and will only benefit addons that make heavy use of facebook profile info.

library/XenForo/Helper/Facebook.php

PHP:
public static function getUserInfo($accessToken, $path = 'me') { try { if(empty($accessToken) && $path != 'me'){ $cache = XenForo_Application::getCache(); $cacheResult = $cache->load("facebook_profile_{$path}"); } if(empty($cacheResult)){ $client = XenForo_Helper_Http::getClient('https://graph.facebook.com/' . $path); if ($accessToken) { $client->setParameterGet('access_token', $accessToken); } $response = $client->request('GET'); $cacheResult = json_decode($response->getBody(), true); if(empty($accessToken) && $path != 'me'){ $cache->save($cacheResult, "facebook_profile_{$path}", array(), 86400*3); } } return $cacheResult; } catch (Zend_Http_Client_Exception $e) { XenForo_Error::logException($e); return false; } }

 
Geri
Yukarı