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


PHP Request::get方法代码示例

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


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

示例1: consultaTransacao

 public function consultaTransacao($dadosCriptografados)
 {
     $xml = Request::get(static::URL_CONSULTA_TRANSACOES . $dadosCriptografados)->withoutStrictSsl()->expectsXml()->send();
     if (!$xml) {
         throw new \Exception("Nenhum dado coletado no webservice");
     }
     if ($xml->code != 200) {
         throw new \Exception("O servidor retornou status {$xml->code}");
     }
     return $this->populateConsultaTransacao($xml->body);
 }
开发者ID:dilneiss,项目名称:itaubankline,代码行数:11,代码来源:ItauBanklineService.php

示例2: testCitiesListContainsAmsterdam

 public function testCitiesListContainsAmsterdam()
 {
     $uri = "http://localhost:8000";
     $response = Request::get($uri)->send();
     $this->assertEquals("application/json", $response->headers["Content-Type"]);
     $this->assertContains("Amsterdam", $response->body);
 }
开发者ID:clamdrive,项目名称:getting-started-php,代码行数:7,代码来源:ResponseTest.php

示例3: getRates

 public function getRates(Currency $base)
 {
     $rates = (array) Request::get(sprintf('http://api.fixer.io/latest?base=%s', $base->getName()))->send()->body->rates;
     $ret = [];
     foreach ($rates as $key => $rate) {
         $ret[$key] = $rate;
     }
     return $ret;
 }
开发者ID:pekkis,项目名称:currency-converter,代码行数:9,代码来源:FixerIoRateProvider.php

示例4: getPhotos

function getPhotos($category, $posts)
{
    $is_highlights = !is_array($posts);
    $data = !$is_highlights ? $posts : [];
    $url = 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'cms/wp-json/posts?filter[posts_per_page]=-1&filter[order]=desc&filter[orderby]=post_date' . ($is_highlights ? '&filter[category_name]=destaque' : null);
    $response = \Httpful\Request::get($url)->send();
    $catId = get_cat_ID($category);
    foreach ($response->body as $key => $post) {
        $image_src = getImage($post->content);
        $attachment_id = pn_get_attachment_id_from_url($image_src);
        $image_large_src = wp_get_attachment_image_src($attachment_id, 'large');
        if (!$is_highlights && !isHighgligthCategory($catId, $post->terms->category)) {
            if ($image_src) {
                array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
            }
        } else {
            if ($is_highlights && isHighgligthCategory($catId, $post->terms->category)) {
                if ($image_src) {
                    array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
                }
            }
        }
    }
    return $data;
}
开发者ID:heldrida,项目名称:freedomnow,代码行数:25,代码来源:helperFns.php

示例5: httpGet

 protected function httpGet($uri)
 {
     $results = [];
     // Start requesting at page 1
     $page = 1;
     // We dont know how many pages there are, so assume 1 until we know
     $pagecount = 1;
     while ($page <= $pagecount) {
         $this->log[] = ['request' => ['method' => 'GET', 'uri' => $uri . '?page=' . $page]];
         $response = \Httpful\Request::get($uri . '?page=' . $page)->addHeader('X-Auth-Email', $this->email)->addHeader('X-Auth-Key', $this->apikey)->expectsType(\Httpful\Mime::JSON)->parseWith(function ($body) {
             return \Metaclassing\Utility::decodeJson($body);
         })->send()->body;
         $this->log[count($this->log) - 1]['response'] = $response;
         if ($response['success'] != true) {
             throw new \Exception("get {$uri} unsuccessful" . \Metaclassing\Utility::encodeJson($response));
         }
         foreach ($response['result'] as $result) {
             array_push($results, $result);
         }
         // Now that we KNOW the pagecount, update that and increment our page counter
         $pagecount = $response['result_info']['total_pages'];
         // And get the next page ready for the next request
         $page++;
     }
     return $results;
 }
开发者ID:metaclassing,项目名称:utility,代码行数:26,代码来源:CloudflareDNSClient.php

示例6: getResponse

 private function getResponse($url)
 {
     $response = \Httpful\Request::get($url)->send();
     $responseraw = $response->raw_body;
     $result = json_decode($responseraw, true);
     return $result;
 }
开发者ID:ibnumubarok,项目名称:www,代码行数:7,代码来源:PagesController.php

示例7: sendRequest

 private function sendRequest($url, $data, array $options = null, $auth = null, $apiKey = null)
 {
     array_merge($this->_headers, $options);
     if ($this->_method == GET) {
         $url = $url . http_build_query($data);
         $this->_result = Request::get($url)->send();
     } else {
         if ($this->_method == POST) {
             if (isset($apiKey)) {
                 $url .= array_keys($apiKey)[0] . "=" . array_values($apiKey)[0];
             }
             $request = Request::post($url);
             foreach ($this->_headers as $key => $hdr) {
                 $request = $request->addHeader($key, $hdr);
             }
             if ($this->headers["Content-Type"] = "application/x-www-form-urlencoded" and is_array($data)) {
                 $request = $request->body(http_build_query($data));
             } else {
                 $request = $request->body($data);
             }
             if (isset($auth)) {
                 $request = $request->authenticateWith(array_keys($auth)[0], array_values($auth)[0]);
             }
             $this->_result = $request->send();
         }
     }
 }
开发者ID:sumutcan,项目名称:SIWCMS,代码行数:27,代码来源:Operation.php

示例8: getNewsObjects

function getNewsObjects()
{
    //CACHING ENABLED: The server will only fetch news again if the cache has expired. Set expiry values in caching.php
    /*************** CACHE **************/
    $newsCacheName = 'newscache';
    $responsejson = null;
    $cacheExpired = is_null(checkCache($newsCacheName));
    $noCache = !is_null($_GET["nocache"]);
    ////////////////////////
    if ($cacheExpired || $noCache) {
        $uri = "http://api.nytimes.com/svc/news/v3/content/all/all.json?api-key={$newsapikey}";
        $rawresponsejson = \Httpful\Request::get($uri)->send();
        $responsejson = $rawresponsejson . raw_body;
        setCacheVal($newsCacheName, $responsejson);
        if ($debug) {
            echo "Fetched.";
        }
    } else {
        if ($debug) {
            echo "From cache.";
        }
        $responsejson = getCacheVal($newsCacheName);
    }
    return parseArticleObjectsFromJson($responsejson);
}
开发者ID:GeoForTomorrow,项目名称:mapnews,代码行数:25,代码来源:news.php

示例9: get

 /**
  * {@inheritdoc}
  */
 public function get($url)
 {
     $response = Request::get($url)->sendsJson()->addHeader("Accept", "application/json")->addHeader('X-TOKEN', $this->api)->send();
     if ($this->isResponseOk($response->code)) {
         return $response->body;
     }
 }
开发者ID:uaktags,项目名称:ngcsWP,代码行数:10,代码来源:HttpAdapter.php

示例10: fetch

 private function fetch(&$str, $productid, $page, $count)
 {
     echo 'page is ' . $page . PHP_EOL;
     //        echo 'current str length is '.strlen($str).PHP_EOL;
     $has_more = true;
     $url = sprintf($this->url_format, $productid, $page, $count);
     $headers = ['Cookie' => '_customId=q77dbffe7014; _snmc=1; _snsr=direct%7Cdirect%7C%7C%7C; _snma=1%7oC143589353017297011%7C1435893530172%7C1435893530172%7C1435893530171%7C1%7C1; _snmp=143589353016073744; _snmb=143589353017914712%7C1435893530308%7C1435893530180%7C1; _ga=GA1.2.833540218.1435893530; _snmz=143589353016073744%7C%281049%2C3268%29'];
     try {
         $response_ = Request::get($url)->addHeaders($headers)->autoParse(false)->send();
     } catch (\Exception $e) {
         return false;
     }
     //生成一个csv文件格式
     $json_str = substr($response_->raw_body, 11, -1);
     $arr = json_decode($json_str, true);
     //        echo 'json_str is '.$json_str.PHP_EOL;
     //        echo 'current json_str length is '.strlen($json_str).PHP_EOL;
     if (strlen($json_str) > 0 && !is_null($arr) && isset($arr['commodityReviews'])) {
         //echo "commodity reviews arr count is ".count($arr['commodityReviews']).PHP_EOL;
         foreach ($arr['commodityReviews'] as $comment) {
             $content = $comment['content'];
             str_replace('\'', '', $content);
             str_replace('"', '', $content);
             str_replace(',', '', $content);
             $str .= $content . "\r\n";
         }
     } else {
         $has_more = false;
     }
     return $has_more;
 }
开发者ID:sxpd7788,项目名称:suning-comment,代码行数:31,代码来源:MainTask.php

示例11: authenticate

 public function authenticate($ticket, $service)
 {
     $r = Request::get($this->getValidateUrl($ticket, $service))->sendsXml()->timeoutIn($this->timeout)->send();
     $r->body = str_replace("\n", "", $r->body);
     try {
         $xml = new SimpleXMLElement($r->body);
     } catch (\Exception $e) {
         throw new \UnexpectedValueException("Return cannot be parsed : '{$r->body}'");
     }
     $namespaces = $xml->getNamespaces();
     $serviceResponse = $xml->children($namespaces['cas']);
     $user = $serviceResponse->authenticationSuccess->user;
     if ($user) {
         return (string) $user;
         // cast simplexmlelement to string
     } else {
         $authFailed = $serviceResponse->authenticationFailure;
         if ($authFailed) {
             $attributes = $authFailed->attributes();
             throw new \Exception((string) $attributes['code']);
         } else {
             throw new \Exception($r->body . " service:" . $service);
         }
     }
     // never reach there
 }
开发者ID:PayIcam,项目名称:shotgun,代码行数:26,代码来源:Cas.php

示例12: fetchOriginal

 public function fetchOriginal($showTitle, $season, $episode)
 {
     $episodeLink = $this->fetchEpisodeLink($showTitle, $season, $episode);
     $doc = Request::get($episodeLink)->send()->body;
     $dom = new DOMDocument('1.0', 'utf-8');
     @$dom->loadHTML($doc);
     $xp = new DOMXPath($dom);
     $links = $xp->query('//strong[text()="original"]');
     if ($links->length == 0) {
         $links = $xp->query('//table[@class="tabel95"]//td[@class="language"][contains(text(),"English")]');
         if ($links->length == 0) {
             echo "Subtitle not found: {$episodeLink}\n";
             return;
         } else {
             $tds = $links;
             $links = [];
             foreach ($tds as $td) {
                 $linkNode = $xp->query('../td/a[@class="buttonDownload"]/strong', $td)->item(0);
                 if ($linkNode) {
                     $links[] = $linkNode;
                 }
             }
         }
     }
     foreach ($links as $linkNode) {
         $link = $linkNode->parentNode->getAttribute('href');
         $subLink = "http://www.addic7ed.com{$link}";
         $response = Request::get($subLink)->addHeader('Referer', $episodeLink)->send();
         $disp = $response->headers['Content-Disposition'];
         preg_match('/filename="([^"]+)"/', $disp, $m);
         return ['filename' => $m[1], 'body' => $response->body];
     }
 }
开发者ID:kipelovets,项目名称:rss,代码行数:33,代码来源:Addic7ed.php

示例13: getHttpServer

 /**
  * @param Request $request
  *
  * @return HttpServer
  */
 public function getHttpServer(Request $request)
 {
     $url = $request->getUri();
     switch ($request->getMethod()) {
         case Request::METHOD_POST:
             $httpServer = HttpServer::post($url);
             break;
         case Request::METHOD_PUT:
             $httpServer = HttpServer::put($url);
             break;
         case Request::METHOD_DELETE:
             $httpServer = HttpServer::delete($url);
             break;
         default:
             $httpServer = HttpServer::get($url);
             break;
     }
     if ($request->headers) {
         $httpServer->addHeaders($request->headers->all());
     }
     if ($request->getUser()) {
         $httpServer->authenticateWith($request->getUser(), $request->getPassword());
     }
     if ($request->getContent()) {
         $httpServer->body($request->getContent());
     }
     return $httpServer;
 }
开发者ID:dongww,项目名称:web-monitor,代码行数:33,代码来源:Http.php

示例14: send

 /**
  * Send the HipChat message.
  *
  * @return void
  */
 public function send()
 {
     $message = $this->message ?: ucwords($this->getSystemUser()) . ' ran the [' . $this->task . '] task.';
     $format = $message != strip_tags($message) ? 'html' : 'text';
     $payload = ['auth_token' => $this->token, 'room_id' => $this->room, 'from' => $this->from, 'message' => $message, 'message_format' => $format, 'notify' => 1, 'color' => $this->color];
     Request::get('https://api.hipchat.com/v1/rooms/message?' . http_build_query($payload))->send();
 }
开发者ID:awoyele,项目名称:omc,代码行数:12,代码来源:Hipchat.php

示例15: resetDatabase

 /**
  * Reset passbolt installation
  * @return bool
  */
 public static function resetDatabase($url, $dummy = 'seleniumtests')
 {
     $response = \Httpful\Request::get($url . '/seleniumTests/resetInstance/' . $dummy)->send();
     $seeCreated = preg_match('/created/', $response->body);
     sleep(2);
     // Wait for database to be imported (no visible output).
     return $seeCreated;
 }
开发者ID:passbolt,项目名称:passbolt_selenium,代码行数:12,代码来源:PassboltServer.php


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