当前位置: 首页>>代码示例>>PHP>>正文


PHP kFile::downloadUrlToString方法代码示例

本文整理汇总了PHP中kFile::downloadUrlToString方法的典型用法代码示例。如果您正苦于以下问题:PHP kFile::downloadUrlToString方法的具体用法?PHP kFile::downloadUrlToString怎么用?PHP kFile::downloadUrlToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kFile的用法示例。


在下文中一共展示了kFile::downloadUrlToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendRequest

 private static function sendRequest($params, $url = "rest")
 {
     $fullUrl = self::buildUrl($params, $url);
     $rsp = kFile::downloadUrlToString($fullUrl);
     $rsp_obj = unserialize($rsp);
     return $rsp_obj;
 }
开发者ID:DBezemer,项目名称:server,代码行数:7,代码来源:myFlickrServices.class.php

示例2: search

 private static function search($searchText, $page, $pageSize)
 {
     if (!$pageSize) {
         $pageSize = 100;
     }
     $pageSize = min($pageSize, 100);
     $startIndex = ($page - 1) * $pageSize;
     $url = self::$domain . "/api/videos/?vq=" . urlencode($searchText) . "&max-results=" . $pageSize . "&start-index=" . $startIndex . "&time=all_time";
     $content = kFile::downloadUrlToString($url);
     return $content;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:11,代码来源:myMetacafeServices.class.php

示例3: execute

 public function execute()
 {
     $error = false;
     // youtube video id
     $itemId = $this->getRequestParameter("itemId");
     $url = "http://www.youtube.com/watch?v=" . $itemId;
     $sourceUrl = "";
     $retries = 2;
     while ($retries--) {
         $content = kFile::downloadUrlToString($url, 3);
         if (preg_match('/swfArgs.*?\\{.*?, "t":\\s*"(.*?)"/s', $content, $timestampMatch)) {
             $fmt_url = "";
             //"fmt_map": "35/640000/9/0/115,18/512000/9/0/115,34/0/9/0/115,5/0/7/0/0"
             if (preg_match('/swfArgs.*?\\{.*?, "fmt_map":\\s*"(.*?)"/s', $content, $fmt_map)) {
                 $fmt_map_array = explode(",", urldecode($fmt_map[1]));
                 $fmt_details = explode("/", $fmt_map_array[0]);
                 if ($fmt_details[0]) {
                     $fmt_url = "&fmt=" . $fmt_details[0];
                 }
             }
             //var swfArgs = {hl:'en',video_id:'F924-D-g5t8',l:'24',t:'OEgsToPDskL9BIntclUB-PPzMEpVQKo8',sk:'xXvbHpmFGQKgv-b9__DkgwC'};
             $tId = $timestampMatch[1];
             $sourceUrl = "http://youtube.com/get_video?video_id=" . $itemId . "&t={$tId}{$fmt_url}";
         } else {
             KalturaLog::log("youtubeRedirectAction {$retries} {$url} {$content}");
         }
     }
     if ($sourceUrl) {
         if (!$retries) {
             KalturaLog::log("youtubeRedirectAction retry successful {$url}");
         }
     } else {
         die;
     }
     // get only the headers and don't follow the location redirect
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $sourceUrl);
     curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.11.1");
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_NOBODY, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     $headers = curl_exec($ch);
     // get the location header
     $found1 = preg_match_all('/Location: (.*)/', $headers, $swfUrlResult);
     $swfUrl = str_replace('Location: ', '', $swfUrlResult[0][count($swfUrlResult[0]) - 1]);
     //echo $swfUrl; die();
     $this->redirect($swfUrl);
 }
开发者ID:DBezemer,项目名称:server,代码行数:49,代码来源:youtubeRedirectAction.class.php

示例4: sendRequest

 public static function sendRequest($url)
 {
     $images = array();
     $message = '';
     $xmlStr = kFile::downloadUrlToString($url);
     $doc = new DOMDocument();
     $doc->loadXML($xmlStr);
     $xpath = new DOMXPath($doc);
     $sounds = $xpath->query("//item");
     $objects = array();
     //get only "by"
     //<cc:license>http://creativecommons.org/licenses/by/2.5/</cc:license>
     foreach ($sounds as $sound) {
         $objects[] = array('url' => self::getXmlNodeValue($sound, "enclosure", "url"), 'title' => self::getXmlNodeValue($sound, "title") . " by " . self::getXmlNodeValue($sound, "creator"), 'id' => self::getXmlNodeValue($sound, "guid"), 'thumb' => self::AUDIO_THUMB_URL);
     }
     $status = 'ok';
     /*
     {
     	$status = 'error';
     	$message = $rsp_obj['code'].' : '.$rsp_obj['message'];
     }
     */
     return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:24,代码来源:myCCMixterServices.class.php

示例5: searchImages

 private static function searchImages($searchText, $page, $pageSize)
 {
     if (!parse_url($searchText, PHP_URL_SCHEME)) {
         $searchText = "http://{$searchText}";
     }
     $headers = kFile::downloadUrlToString($searchText, 2);
     $images = array();
     $message = "";
     if (preg_match("/Content-Type:\\s*image\\/(.*)\r/i", $headers, $matches)) {
         if ($matches[1] == "gif" || $matches[1] == "jpeg" || $matches[1] == "png" || $matches[1] == "bmp") {
             $title = self::getFilenameFromUrl($searchText);
             $images[] = array('thumb' => $searchText, 'title' => $title, 'url' => $searchText, 'id' => $searchText);
         }
     } else {
         if (preg_match("/Content-Type:\\s*text\\/html;?.*\r/i", $headers)) {
             $content = kFile::downloadUrlToString($searchText, 1);
             return self::parseImages($content, $searchText, $page, $pageSize);
         }
     }
     if (!count($images)) {
         $message = 'No Images found';
     }
     $status = 'ok';
     return array('status' => $status, 'message' => $message, 'objects' => $images, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:25,代码来源:myUrlImportServices.class.php

示例6: execute

 public function execute()
 {
     $error = false;
     // metacafe video id
     $itemId = $this->getRequestParameter("itemId");
     $url = "http://www.metacafe.com/api/item/" . $itemId;
     $content = kFile::downloadUrlToString($url);
     $doc = new DOMDocument();
     if ($doc->loadXML($content)) {
         $xpath = new DOMXPath($doc);
         $itemNodes = $xpath->query("//item");
         if (!$itemNodes->length) {
             $error = true;
         } else {
             $itemNode = $itemNodes->item(0);
             $ns = "http://search.yahoo.com/mrss/";
             $swfUrl = self::getXmlNodeValue($itemNode, "content", "url", $ns);
             if (!$swfUrl) {
                 die('no content url in item [' . $swfUrl . ']. cannot fetch headers for [' . $swfUrl . ']');
             }
             // get only the headers and don't follow the location redirect
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $swfUrl);
             curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.11.1");
             curl_setopt($ch, CURLOPT_HEADER, 1);
             curl_setopt($ch, CURLOPT_NOBODY, 1);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
             $headers = curl_exec($ch);
             // get the location header
             $found1 = preg_match('/Location: (.*?)$/ms', $headers, $swfUrlResult);
             $swfUrl = urldecode($swfUrlResult[1]);
             $found2 = preg_match('/mediaURL=(.*?)&/ms', $swfUrl, $flvResult);
             if (!$found2) {
                 // sometimes the format in metacafe response is not the same and they return some kind of JSON
                 $found2 = preg_match('/mediaURL\\"\\:\\"(.*?)\\"/ms', $swfUrl, $flvResult);
                 // this is another match for MediaURL in metacafe response
                 $found2_alt = preg_match('/mediaURL":"(.*?)"/ms', $swfUrl, $flvResult);
                 if ($found2_alt && !$found2) {
                     $found2 = $found2_alt;
                 }
                 if (!$found2) {
                     die('could not process metacafe output: ' . print_r($swfUrl, true));
                 }
             }
             $flv = stripslashes(urldecode($flvResult[1]));
             $flv = urldecode($flv);
             $found3 = preg_match('/gdaKey=(.*?)&/ms', $swfUrl, $keyResult);
             // in another response of MetaCafe, the parameter is called key and not gdaKey
             if (!$found3) {
                 $found3 = preg_match('/key":"(.*?)"/ms', $swfUrl, $keyResult);
             }
             $flv = $flv . "?__gda__=" . (isset($keyResult[1]) ? $keyResult[1] : '');
             $flv = str_replace(' ', '%20', $flv);
             // replacing square brackets so curl will not break the redirect
             $flv = str_replace('[', '%5B', $flv);
             $flv = str_replace(']', '%5D', $flv);
             $this->redirect($flv);
         }
     } else {
         $error = true;
     }
     if ($error) {
         die("File not found");
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:66,代码来源:metacafeRedirectAction.class.php

示例7: myBatchFlattenServer

 public function myBatchFlattenServer($script_name)
 {
     $this->script_name = $script_name;
     $this->register($script_name);
     SET_CONTEXT("FS");
     $MAX_ITERATIONS_DUE_TO_PROPEL_MEMORY_LEAK = 10000000;
     self::initDb();
     list($sleep_between_cycles, $number_of_times_to_skip_writing_sleeping) = self::getSleepParams('app_flatten_');
     $last_worker_count = 0;
     $iteration = 0;
     $c = new Criteria();
     $currentDc = kDataCenterMgr::getCurrentDc();
     $c->add(BatchJobPeer::DC, kDataCenterMgr::getCurrentDcId());
     $c->add(BatchJobPeer::JOB_TYPE, BatchJobType::FLATTEN);
     $c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_PROCESSED);
     $temp_count = 0;
     while (1) {
         self::exitIfDone();
         try {
             sleep($sleep_between_cycles);
             $jobs = BatchJobPeer::doSelect($c);
             foreach ($jobs as $job) {
                 $data = json_decode($job->getData(true), true);
                 $entry_id = $data['entryId'];
                 $entry_int_id = $data['entryIntId'];
                 $entry_version = $data['entryVersion'];
                 $file_format = $data['fileFormat'];
                 $entry = entryPeer::retrieveByPK($entry_id);
                 if (!$entry) {
                     // entry is probably deleted if it is not returned from retrieveByPK
                     // close job as failed
                     $job->setStatus(BatchJob::BATCHJOB_STATUS_FAILED);
                     $job->setDescription("could not retrieve entry, probably deleted");
                     TRACE("could not retrieve entry {$entry_id} , probably deleted");
                     $job->save();
                     continue;
                 }
                 $fileSyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DOWNLOAD, $file_format);
                 $fullFinalPath = kFileSyncUtils::getLocalFilePathForKey($fileSyncKey);
                 $finalPathNoExt = substr($fullFinalPath, 0, strlen($fullFinalPath) - strlen($file_format));
                 myContentStorage::fullMkdir($fullFinalPath);
                 $wildcardFinalPath = $finalPathNoExt . "*";
                 $older_files = glob($wildcardFinalPath);
                 foreach ($older_files as $older_file) {
                     TRACE("removing old file: [{$older_file}]");
                     @unlink($older_file);
                 }
                 TRACE("Downloading: {$fullFinalPath}");
                 kFile::downloadUrlToFile($data["serverUrl"], $fullFinalPath);
                 if (!file_exists($fullFinalPath)) {
                     TRACE("file doesnt exist: " . $data["serverUrl"]);
                     $job->setDescription("file doesnt exist: " . $data["serverUrl"]);
                     $job->setStatus(BatchJob::BATCHJOB_STATUS_FAILED);
                 } else {
                     if (filesize($fullFinalPath) < 100000) {
                         @unlink($fullFinalPath);
                         TRACE("file too small: " . $data["serverUrl"]);
                         $job->setDescription("file too small: " . $data["serverUrl"]);
                         $job->setStatus(BatchJob::BATCHJOB_STATUS_FAILED);
                     } else {
                         if ($data['email']) {
                             $downloadLink = $entry->getDownloadUrl() . '/format/' . $file_format;
                             kJobsManager::addMailJob(null, $entry_id, $entry->getPartnerId(), self::KALTURAS_FLATTEN_READY, kMailJobData::MAIL_PRIORITY_NORMAL, kConf::get("batch_flatten_video_sender_email"), kConf::get("batch_flatten_video_sender_name"), $data['email'], array($data['email'], $downloadLink));
                         }
                         TRACE("Deleting: " . $data["deleteUrl"]);
                         kFile::downloadUrlToString($data["deleteUrl"]);
                         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $entry);
                         $job->setStatus(BatchJob::BATCHJOB_STATUS_FINISHED);
                         $filePath = kFileSyncUtils::getLocalFilePathForKey($fileSyncKey);
                         if (file_exists($filePath)) {
                             try {
                                 kFileSyncUtils::createSyncFileForKey($fileSyncKey);
                             } catch (Exception $ex) {
                                 TRACE("ignore ERROR: " . $ex->getMessage());
                             }
                         } else {
                             TRACE("The file [{$filePath}] doesn't exists, not creating FileSync");
                         }
                     }
                 }
                 $job->save();
             }
         } catch (Exception $ex) {
             TRACE("ERROR: " . $ex->getMessage());
             self::initDb(true);
             self::failed();
         }
         if ($temp_count == 0) {
             TRACE("Ended conversion. sleeping for a while (" . $sleep_between_cycles . " seconds). Will write to the log in (" . $sleep_between_cycles * $number_of_times_to_skip_writing_sleeping . ") seconds");
         }
         $temp_count++;
         if ($temp_count >= $number_of_times_to_skip_writing_sleeping) {
             $temp_count = 0;
         }
     }
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:96,代码来源:myBatchFlattenVideo.class.php

示例8: getObjectInfo

 private function getObjectInfo($objectId)
 {
     $url = self::$domain . $objectId;
     $htmlPage = kFile::downloadUrlToString($url);
     $status = 'error';
     $message = '';
     $objectInfo = null;
     $tags = '';
     $flv = '';
     $thumbnail = '';
     $foundFlv = false;
     if (preg_match('/IAD.flvs = \\["(.*)"\\];/', $htmlPage, $pregResult)) {
         $flv = "/download/" . $pregResult[1];
         $foundFlv = true;
     } else {
         if (self::findAlternativeVideo('MPEG4', $htmlPage)) {
             $flv = self::findAlternativeVideo('MPEG4', $htmlPage);
             $foundFlv = true;
         } else {
             if (self::findAlternativeVideo('256Kb MPEG4', $htmlPage)) {
                 $flv = self::findAlternativeVideo('256Kb MPEG4', $htmlPage);
                 $foundFlv = true;
             } else {
                 if (self::findAlternativeVideo('64Kb MPEG4', $htmlPage)) {
                     $flv = self::findAlternativeVideo('64Kb MPEG4', $htmlPage);
                     $foundFlv = true;
                 } else {
                     if (self::findAlternativeVideo('Windows Media', $htmlPage)) {
                         $flv = self::findAlternativeVideo('Windows Media', $htmlPage);
                         $foundFlv = true;
                     } else {
                         if (self::findAlternativeVideo('QuickTime', $htmlPage)) {
                             $flv = self::findAlternativeVideo('QuickTime', $htmlPage);
                             $foundFlv = true;
                         } else {
                             if (self::findAlternativeVideo('MPEG1', $htmlPage)) {
                                 $flv = self::findAlternativeVideo('MPEG1', $htmlPage);
                                 $foundFlv = true;
                             } else {
                                 if (self::findAlternativeVideo('MPEG2', $htmlPage)) {
                                     $flv = self::findAlternativeVideo('MPEG2', $htmlPage);
                                     $foundFlv = true;
                                 } else {
                                     if (self::findAlternativeVideo('Other', $htmlPage)) {
                                         $flv = self::findAlternativeVideo('Other', $htmlPage);
                                         $foundFlv = true;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($foundFlv) {
         $flv = self::$domain . $flv;
         // find alternative thumbnail
         if (!$thumbnail) {
             $regex = '/<img title="\\[item image\\]"\\s*alt="\\[item image\\]"\\s*(style="([^"]*)"\\s){0,2}\\s*src="([^"]*)"\\/>/i';
             if (preg_match($regex, $htmlPage, $pregResult)) {
                 $thumbnail = $pregResult[3];
             }
         }
         if (preg_match('/Keywords:<\\/span>(.*?)<\\/span>/', $htmlPage, $tagsResult)) {
             $tags = strip_tags(@$tagsResult[1]);
             // remove ; and  :
             $tags = trim($tags);
             $tags = str_replace(array(";", ":"), ",", $tags);
             $tagsArray = explode(",", $tags);
             // make unique
             $tagsArray = array_unique($tagsArray);
             $tagsArray = array_values($tagsArray);
             // remove white spaces
             for ($i = 0, $len = count($tagsArray); $i < $len; $i++) {
                 $tagsArray[$i] = trim($tagsArray[$i]);
             }
             // back to string
             $tags = implode(", ", $tagsArray);
         }
         $objectInfo = array('id' => $objectId, 'url' => $flv, 'tags' => $tags, 'thumbnail' => $thumbnail, 'license' => '', 'credit' => '', 'flash_playback_type' => 'none');
         $status = 'ok';
     }
     return array('status' => $status, 'message' => $message, 'objectInfo' => $objectInfo);
 }
开发者ID:DBezemer,项目名称:server,代码行数:85,代码来源:myArchiveOrgServices.class.php

示例9: getObjectInfo

 private static function getObjectInfo($objectId)
 {
     $source_link = "http://current.com{$objectId}";
     $htmlPage = kFile::downloadUrlToString($source_link, 1);
     $status = 'error';
     $message = '';
     $objectInfo = null;
     //video might be an embed from youtube
     //<a target="_blank" title="http://www.youtube.com/watch?v=0XxFjTdHYcA" href="http://www.youtube.com/watch?v=0XxFjTdHYcA">http://www.youtube.com/watch?v=0XxFjTdHYcA</a>
     if (preg_match('/<div id="itemSourceLink">(.*)<\\/div>/ms', $htmlPage, $matches)) {
         if (preg_match('/<a.*title="http:\\/\\/www\\.youtube\\.com\\/watch\\?v=(.*?)"/ms', $matches[1], $matches)) {
             return myYouTubeServices::getObjectInfo($matches[1]);
         }
     }
     //so.addVariable('imgPath', 'http://i.current.com/images/studio/asset/2007/05/31/36576944_392115194_400x300.jpg');
     //so.addVariable('vidPath', 'http://v.current.com/vids/2007/05/31/20070531_36579189_36576944_3.flv');
     if (preg_match("/'vidPath', '(.*?)'/ms", $htmlPage, $matches)) {
         $url = $matches[1];
         if (preg_match("/'imgPath', '(.*?)'/ms", $htmlPage, $matches)) {
             $thumb = $matches[1];
             $objectInfo = array('id' => $objectId, 'url' => $url, 'thumb' => $thumb, 'source_link' => $source_link);
             //'license' => '', 'credit' => '');
             $status = 'ok';
         }
     }
     return array('status' => $status, 'message' => $message, 'objectInfo' => $objectInfo, "needMediaInfo" => self::$NEED_MEDIA_INFO);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:27,代码来源:myCurrentServices.class.php

示例10: getObjectInfo

 private static function getObjectInfo($objectId)
 {
     $htmlPage = kFile::downloadUrlToString("http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid={$objectId}");
     $status = 'error';
     $message = '';
     $objectInfo = null;
     $title = '';
     $tags = '';
     $flvUrl = '';
     // 2009-10-19: mySpace changed the HTML result.
     // It may be that there are 2 <h1> tags
     if (preg_match('/<h1.*?tv_tbar.*?>(.*?)<\\/h1>/', $htmlPage, $titleTag)) {
         $title = $titleTag[1];
         if (preg_match('/<a.*?>(.*?)<\\/a>/', $title, $titleInnerValue)) {
             $title = $titleInnerValue[1];
         }
         if (preg_match('/<div.*?>.*?Tags:(.*?)<\\/div>/ms', $htmlPage, $tagsContainer)) {
             if (preg_match_all('/<a href.*?>(.*?)<\\/a>/ms', $tagsContainer[1], $tagsWords)) {
                 $tags = implode(',', $tagsWords[1]);
             }
         }
         $rssFeed = kFile::downloadUrlToString("http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID={$objectId}");
         if (preg_match_all('/<media:content url="(.*?)"/ms', $rssFeed, $urlAttr)) {
             $flvUrl = $urlAttr[1][0];
         }
         /*
         else
         {
         	$len = strlen($videoFlvId);
         	$flvUrl = sprintf("http://content.movies.myspace.com/%07d/%s%s/%s%s/%d.flv",
         	floor($videoFlvId / 100000), $videoFlvId[--$len], $videoFlvId[--$len],
         	$videoFlvId[--$len], $videoFlvId[--$len], $videoFlvId);
         }
         */
         $objectInfo = array('id' => $objectId, 'title' => $title, 'url' => $flvUrl, 'tags' => $tags, 'license' => '', 'credit' => '');
         $status = 'ok';
     }
     return array('status' => $status, 'message' => $message, 'objectInfo' => $objectInfo);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:39,代码来源:myMySpaceServices.class.php

示例11: getObjectInfo

 private static function getObjectInfo($objectId)
 {
     $url = "http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=" . self::DEV_ID . "&video_id=" . urlencode($objectId);
     $xpath = self::getXPathResponse($url);
     $title = '';
     $tags = '';
     $credit = '';
     if ($xpath) {
         $videos = $xpath->query("//video_details");
         foreach ($videos as $video) {
             $title = self::getXmlNodeValue($video, "title");
             $tags = implode(',', explode(' ', self::getXmlNodeValue($video, "tags")));
             $credit = self::getXmlNodeValue($video, "author");
         }
     }
     $source_link = "http://www.youtube.com/watch?v=" . $objectId;
     $htmlPage = kFile::downloadUrlToString($source_link, 3);
     $status = 'error';
     $message = '';
     $objectInfo = null;
     if (preg_match('/Location: (.*?)\\/verify_age/', $htmlPage)) {
         $message = "Adult content, age verification required, Please choose another movie";
     } else {
         if (preg_match('/swfArgs.*?\\{.*?, "t":\\s*"(.*?)"/s', $htmlPage, $timestampMatch) || preg_match('/SWF_ARGS.*?\\{.*?, "t":\\s*"(.*?)"/s', $htmlPage, $timestampMatch)) {
             //var swfArgs = {"sourceid": "y", "video_id": "CoiFGva_JoY", "l": 64, "sk": "uKKGdPxW5MWYni0u_OXxkgU", "t": "OEgsToPDskKqwUniXcKcELZlXY7Smhdx", "hl": "en", "plid": "AAREdD-JLalob4scAAAAIIAYQAA", "sdetail": "p%3A"};
             $fmt_url = "";
             //"fmt_map": "35/640000/9/0/115,18/512000/9/0/115,34/0/9/0/115,5/0/7/0/0"
             if (preg_match('/swfArgs.*?\\{.*?, "fmt_map":\\s*"(.*?)"/s', $htmlPage, $fmt_map)) {
                 $fmt_map_array = explode(",", $fmt_map[1]);
                 $fmt_details = explode("/", $fmt_map_array[0]);
                 //print_r($fmt_map_array);
                 //echo "fmt: ".$fmt_details[0]."\n";
                 if ($fmt_details[0]) {
                     $fmt_url = "&fmt=" . $fmt_details[0];
                 }
             } elseif (preg_match('/SWF_ARGS.*?\\{.*?, "fmt_map":\\s*"(.*?)"/s', $htmlPage, $fmt_map)) {
                 //"fmt_map": "34%2F0%2F9%2F0%2F115%2C5%2F0%2F7%2F0%2F0"
                 $encoded_fmt_map = urldecode($fmt_map[1]);
                 $fmt_map_array = explode(",", $encoded_fmt_map);
                 $fmt_details = explode("/", $fmt_map_array[0]);
                 //print_r($fmt_map_array);
                 //echo "fmt: ".$fmt_details[0]."\n";
                 if ($fmt_details[0]) {
                     $fmt_url = "&fmt=" . $fmt_details[0];
                 }
             }
             //var swfArgs = {hl:'en',video_id:'F924-D-g5t8',l:'24',t:'OEgsToPDskL9BIntclUB-PPzMEpVQKo8',sk:'xXvbHpmFGQKgv-b9__DkgwC'};
             $tId = $timestampMatch[1];
             //$url = "http://youtube.com/get_video?video_id=".$objectId."&t=$tId$fmt_url";
             $url = requestUtils::getRequestHost() . '/extservices/youtubeRedirect?itemId=' . $objectId;
             $objectInfo = array('id' => $objectId, 'url' => $url, 'title' => $title, 'thumb' => "http://img.youtube.com/vi/{$objectId}/2.jpg", 'tags' => $tags, 'ext' => "flv", 'source_link' => $source_link, 'license' => '', 'credit' => $credit, 'flash_playback_type' => 'video');
             $status = 'ok';
         }
     }
     return array('status' => $status, 'message' => $message, 'objectInfo' => $objectInfo);
 }
开发者ID:DBezemer,项目名称:server,代码行数:56,代码来源:myYouTubeServices.class.php


注:本文中的kFile::downloadUrlToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。