in Helper/FBEHelper.php [380:415]
public function getAPIVersion()
{
$accessToken = $this->getAccessToken();
if ($accessToken == null) {
$this->log("can't find access token, won't get api update version ");
return;
}
$api_version = null;
try {
$configRow = $this->configFactory->create()->load('fb/api/version');
$api_version = $configRow ? $configRow->getConfigValue() : null;
//$this->log("Current api version : ".$api_version);
$versionLastUpdate = $configRow ? $configRow->getUpdateTime() : null;
//$this->log("Version last update: ".$versionLastUpdate);
$is_updated_version = $this->isUpdatedVersion($versionLastUpdate);
if ($api_version && $is_updated_version) {
//$this->log("Returning the version already stored in db : ".$api_version);
return $api_version;
}
$this->curl->addHeader("Authorization", "Bearer " . $accessToken);
$this->curl->get(self::FB_GRAPH_BASE_URL . 'api_version');
//$this->log("The API call: ".self::FB_GRAPH_BASE_URL.'api_version');
$response = $this->curl->getBody();
//$this->log("The API reponse : ".json_encode($response));
$decodeResponse = json_decode($response);
$api_version = $decodeResponse->api_version;
//$this->log("The version fetched via API call: ".$api_version);
$this->saveConfig('fb/api/version', $api_version);
} catch (\Exception $e) {
$this->log("Failed to fetch latest api version with error " . $e->getMessage());
}
return $api_version ? $api_version : self::CURRENT_API_VERSION;
}