本文整理汇总了PHP中api_Utils::GetRemoteFileRealUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP api_Utils::GetRemoteFileRealUrl方法的具体用法?PHP api_Utils::GetRemoteFileRealUrl怎么用?PHP api_Utils::GetRemoteFileRealUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_Utils
的用法示例。
在下文中一共展示了api_Utils::GetRemoteFileRealUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxFilesCheckUrl
/**
* @return array
*/
public function AjaxFilesCheckUrl()
{
$oAccount = $this->GetDefaultAccount();
$mResult = false;
if ($oAccount) {
$sUrl = trim($this->getParamValue('Url', ''));
if (!empty($sUrl)) {
$iLinkType = \api_Utils::GetLinkType($sUrl);
if ($iLinkType === \EFileStorageLinkType::GoogleDrive) {
if ($this->oApiTenants) {
$oTenant = 0 < $oAccount->IdTenant ? $this->oApiTenants->getTenantById($oAccount->IdTenant) : $this->oApiTenants->getDefaultGlobalTenant();
}
$oSocial = $oTenant->getSocialByName('google');
if ($oSocial) {
$oInfo = \api_Utils::GetGoogleDriveFileInfo($sUrl, $oSocial->SocialApiKey);
if ($oInfo) {
$mResult['Size'] = 0;
if (isset($oInfo->fileSize)) {
$mResult['Size'] = $oInfo->fileSize;
} else {
$aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
$mResult['Size'] = $aRemoteFileInfo['size'];
}
$mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
$mResult['Thumb'] = isset($oInfo->thumbnailLink) ? $oInfo->thumbnailLink : null;
}
}
} else {
//$sUrl = \api_Utils::GetRemoteFileRealUrl($sUrl);
$oInfo = \api_Utils::GetOembedFileInfo($sUrl);
if ($oInfo) {
$mResult['Size'] = isset($oInfo->fileSize) ? $oInfo->fileSize : '';
$mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
$mResult['LinkType'] = $iLinkType;
$mResult['Thumb'] = isset($oInfo->thumbnail_url) ? $oInfo->thumbnail_url : null;
} else {
if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::DropBox) {
$sUrl = str_replace('?dl=0', '', $sUrl);
}
$sUrl = \api_Utils::GetRemoteFileRealUrl($sUrl);
if ($sUrl) {
$aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
$sFileName = basename($sUrl);
$sFileExtension = \api_Utils::GetFileExtension($sFileName);
if (empty($sFileExtension)) {
$sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
$sFileName .= '.' . $sFileExtension;
}
if ($sFileExtension === 'htm') {
$oCurl = curl_init();
\curl_setopt_array($oCurl, array(CURLOPT_URL => $sUrl, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_RETURNTRANSFER => true, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5, CURLOPT_MAXREDIRS => 5));
$sContent = curl_exec($oCurl);
//$aInfo = curl_getinfo($oCurl);
curl_close($oCurl);
preg_match('/<title>(.*?)<\\/title>/s', $sContent, $aTitle);
$sTitle = isset($aTitle['1']) ? trim($aTitle['1']) : '';
}
$mResult['Name'] = isset($sTitle) && strlen($sTitle) > 0 ? $sTitle : urldecode($sFileName);
$mResult['Size'] = $aRemoteFileInfo['size'];
}
}
}
}
}
return $this->DefaultResponse(null, __FUNCTION__, $mResult);
}