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


PHP Network::GetHTTPData方法代码示例

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


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

示例1: Create

 /**
  * @param int $sigId
  * @param int $playerId
  * @param int $bnetServerNum
  * @param string $playerAccount
  * @param int $sigBackgroundIndex
  * @param int $playerStatsIndex
  * @param string $lang
  * @param string $region
  * @param int $characterCode
  * @return boolean
  */
 public static function Create($sigId, $playerId, $bnetServerNum, $playerAccount, $sigBackgroundIndex = 1, $playerStatsIndex, $lang, $region, $characterCode)
 {
     // ник
     preg_match('/[^a-z0-9\\-ǂ]*/ui', $playerAccount, $match);
     if ($match[0]) {
         // с русскими символами
         $fontAccount = 'calibri.ttf';
     } else {
         $fontAccount = 'eurostile_ext_med.otf';
     }
     $fontAccount = SIG_BASEDIR . 'php/' . $fontAccount;
     // echo $playerAccount.' '.$fontAccount."\n";
     // языки \ локали
     $locale['ru']['notRanked'] = ' НЕТ РЕЙТИНГА';
     $locale['ru']['place'] = 'МЕСТО';
     $locale['ru']['points'] = 'ОЧКИ';
     $locale['ru']['region'] = 'РЕГИОН';
     $locale['ru']['wins'] = 'ПОБЕД';
     $locale['en']['notRanked'] = ' NOT YET RANKED';
     $locale['en']['place'] = 'PLACE';
     $locale['en']['points'] = 'POINTS';
     $locale['en']['region'] = 'REGION';
     $locale['en']['wins'] = 'WINS';
     if (!($lang == 'ru' || $lang == 'en')) {
         $lang = 'ru';
     }
     $bnetSubDomain = 'eu';
     if ($region === 'US' || $region === 'KR') {
         $bnetSubDomain = strtolower($region);
     } elseif ($region === 0) {
         $region = false;
     }
     $sigPath = SIG_BASEDIR . $sigId . '.png';
     require_once 'network.php';
     $playerAccountUrl = urlencode($playerAccount);
     $relativePlayerAccountUrl = "/sc2/en/profile/{$playerId}/{$bnetServerNum}/{$playerAccountUrl}/";
     $relativePlayerAccountUrlForRegExp = "/sc2/en/profile/{$playerId}/{$bnetServerNum}/{$playerAccount}/";
     $data = Network::GetHTTPData("http://{$bnetSubDomain}.battle.net" . $relativePlayerAccountUrl . 'ladder/', 'id="portrait', 'class="module-right');
     if (!$data) {
         return false;
     }
     switch ($playerStatsIndex) {
         case 0:
             $playerStatsType = '1v1';
             break;
         case 1:
             $playerStatsType = '2v2';
             break;
         case 2:
             $playerStatsType = '3v3';
             break;
         case 3:
             $playerStatsType = '4v4';
             break;
         default:
             $playerStatsType = '1v1';
             break;
     }
     if ($characterCode) {
         $regionX = 133;
     } else {
         $regionX = 170;
     }
     if ($characterCode || $region) {
         $playerAccountY = 19;
     } else {
         $playerAccountY = 24;
     }
     // получаем число ачивок
     preg_match('/h3>([\\d]*)</si', $data, $match);
     $playerAchievements = $match[1];
     // определяем координаты портрета персонажа
     if (preg_match("#portraits/([-\\d]+).jpg.*?'\\) ([-\\d]+)px ([-\\d]+)px no#si", $data, $match)) {
         // из какой заготовки будем брать
         $portraitImg = 'portraits-' . $match[1];
         // координаты, откуда будем брать
         $portraitX = abs($match[2] * PORTRAIT_KOEFICENT);
         $portraitY = abs($match[3] * PORTRAIT_KOEFICENT);
     } else {
         SaveForDebug("portraitImg is empty, http://{$bnetSubDomain}.battle.net" . $relativePlayerAccountUrl . 'ladder/');
         return FALSE;
     }
     if (preg_match('#<a class="league" href="([\\d]+)\\#current-rank">[\\w\\s]+<strong>' . $playerStatsType . '[\\w\\s]*</strong>.*?<a href="' . $relativePlayerAccountUrlForRegExp . '"[\\s]+class="race-([\\w]+)".*?Rank[\\s]+([\\d]+)#si', $data, $match)) {
         $currentRankUrl = $match[1];
         // место
         $isPlayerHasRank = true;
         $playerRank = $locale[$lang]['place'] . ': ' . $match[3];
         // раса
//.........这里部分代码省略.........
开发者ID:shrz,项目名称:sig,代码行数:101,代码来源:sig.php


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