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


PHP HttpRequest::getResponse方法代码示例

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


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

示例1: fromUrl

 public function fromUrl($url)
 {
     $this->url = $url;
     //		ブログによっては403ではじかれる。ユーザーエージェント?IP?
     $httpRequest = new HttpRequest($this->url);
     $httpRequest->exec();
     $this->fromText($url, $httpRequest->getResponse());
 }
开发者ID:gammodoking,项目名称:kindle.server,代码行数:8,代码来源:HtmlContents.php

示例2: getUserMeta

 function getUserMeta()
 {
     $url = "http://api.twitter.com/1/users/show.json?screen_name=" . $this->user;
     $r = new HttpRequest("get", $url);
     if ($r->getError()) {
         $this->error("Could not get user information");
     } else {
         return json_decode($r->getResponse(), true);
     }
 }
开发者ID:hay,项目名称:wherewereyou,代码行数:10,代码来源:class-tweets.php

示例3: HttpRequest

 function __construct($args)
 {
     $url = $this->formatUrl($args);
     echo "Getting {$url}\n";
     $r = new HttpRequest("get", $url);
     if ($r->getError()) {
         echo $r->getError();
     } else {
         $this->response = json_decode($r->getResponse(), true);
     }
 }
开发者ID:hay,项目名称:hay,代码行数:11,代码来源:dlcomcatcm.php

示例4: getImage

 /**
  * @brief Return the canvas containing the QR code
  *
  * @return Canvas The canvas contianing the QR code
  */
 public function getImage()
 {
     $irequest = new HttpRequest($this->getImageUrl());
     if ($irequest) {
         $img = new StringImage($irequest->getResponse());
         if ($img) {
             return $img;
         }
         throw new BaseException("Could not create canvas from response");
     }
     throw new BaseException("Error requesting QR Code");
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:qrcode.php

示例5: request

 protected function request($url)
 {
     // Check if this is an url or a filename
     if (substr($url, 0, 4) != "http") {
         // File
         return json_decode(file_get_contents($url), true);
     } else {
         $r = new HttpRequest("get", $url);
         if ($r->getError()) {
             return false;
         } else {
             return json_decode($r->getResponse(), true);
         }
     }
 }
开发者ID:hay,项目名称:wherewereyou,代码行数:15,代码来源:class-api-call.php

示例6: t_estXpathSetup

 public function t_estXpathSetup()
 {
     return;
     $datPath = implode('/', [PATH_TEST, 'dat', 'ContentExtractor']);
     //		$res = exec(sprintf('rm -rf %s/*', $datPath), $out);
     foreach ($this->getData() as $name => $testData) {
         $httpRequest = new HttpRequest($testData->url);
         $ret = $httpRequest->exec();
         if (!$ret) {
             d($httpRequest->getError());
             d($httpRequest->getInfo());
         }
         $this->assertEquals(true, $ret);
         file_put_contents($datPath . '/' . $name, $httpRequest->getResponse());
     }
 }
开发者ID:gammodoking,项目名称:kindle.server,代码行数:16,代码来源:ContentExtractorTest.php

示例7: testGeneral

 public function testGeneral()
 {
     $httpRequest = new HttpRequest('http://tuoitre.com.vn/conduongcuqua?q=example_query&page=2&t[]=4');
     $this->assertEquals(['example_query'], $httpRequest->getList('q'));
     $this->assertEquals('example_query', $httpRequest->getParam('q'));
     $this->assertEquals('example_query', $httpRequest->getString('q'));
     $defaultValue = 'testvalue';
     $this->assertEmpty($httpRequest->getGET());
     $this->assertEmpty($httpRequest->getPOST());
     $this->assertNotEmpty($httpRequest->getQuery());
     $this->assertEmpty($httpRequest->getPOST());
     $this->assertEquals('2', $httpRequest->getParam('page'));
     $this->assertEquals(2, $httpRequest->getInt('page'));
     $this->assertEquals(['4'], $httpRequest->getArray('t'));
     $this->assertEmpty([], $httpRequest->getArray('no_array'));
     $this->assertEquals([1], $httpRequest->getArray('no_array', [1]));
     $this->assertEquals($defaultValue, $httpRequest->getParam('no_query', $defaultValue));
     $this->assertEquals($defaultValue, $httpRequest->getString('no_query', $defaultValue));
     $this->assertEquals($defaultValue, $httpRequest->getParam('no_query', $defaultValue));
     $this->assertTrue($httpRequest->isMethod('get'));
     $httpRequest->getResponse();
     $this->assertEmpty($httpRequest->getFragment());
     $httpRequest->setMethod('post');
     $this->assertTrue($httpRequest->isPost());
     $exception = new \RuntimeException('issue');
     $httpRequest->setException($exception);
     $this->assertEquals($exception, $httpRequest->getException());
     $httpRequest->example_params = 12;
     $this->assertEquals($httpRequest->example_params, 12);
     $httpRequest->setPath('/');
     $this->assertEquals($httpRequest->getPath(), '/');
     $httpRequest->setDispatched(false);
     $this->assertFalse($httpRequest->isDispatched());
     $httpRequest->setControllerName('\\Platform\\Core\\Controller\\HomeController');
     $httpRequest->setActionName('index');
     $this->assertEquals($httpRequest->getControllerName(), '\\Platform\\Core\\Controller\\HomeController');
     $this->assertEquals($httpRequest->getActionName(), 'index');
     $httpRequest->dispatch();
     $httpRequest->setParams(['more' => '2']);
     $this->assertNotEmpty($httpRequest->getParams());
     $this->assertEquals('2', $httpRequest->getParam('more'));
     $httpRequest->getFullControllerName();
 }
开发者ID:kendolabdev,项目名称:kendoplatform,代码行数:43,代码来源:HttpRequestTest.php

示例8: die

if (empty($query)) {
    die("No query given\n");
}
echo "Downloading tweets with query '{$query}'\n";
$page = 1;
$baseUrl = "http://search.twitter.com/search.json?q={$query}&rpp=100";
$tweets = array();
do {
    $url = $baseUrl . "&page={$page}";
    echo "REQUEST: {$url} \n";
    $r = new HttpRequest("GET", $url);
    if ($r->getError()) {
        echo "HTTP ERROR: " . $r->getError();
        break;
    } else {
        $json = json_decode($r->getResponse(), true);
        // No more tweets?
        $length = count($json['results']);
        if ($length < 1) {
            echo "NO MORE TWEETS\n";
            break;
        }
        $tweets = array_merge($tweets, $json['results']);
        print_r($tweets);
        file_put_contents("{$query}.json", json_encode($tweets));
        $page++;
    }
} while (true);
// Convert to CSV as well
$csvdata = array_map(function ($tweet) {
    return array("id" => $tweet['id'], "from_user" => $tweet['from_user'], "created_at" => $tweet['created_at'], "text" => $tweet['text']);
开发者ID:hay,项目名称:hay,代码行数:31,代码来源:twitterdl.php

示例9: Query

<?php

$start = $_GET['start'];
$token = $_GET['tok'];
require_once 'query.php';
$q = new Query();
$sql = "select distinct USERID from session where ACCESS_TOKEN={$token}";
$val = $q->getallentires($sql);
//var_dump($val);
//$v=$val['USERID'];
foreach ($val as $value) {
    # code...
    $v = $value['USERID'];
    //echo $v;
}
error_reporting(E_ALL);
ini_set("display_errors", "1");
require_once 'Http2.php';
$r = new HttpRequest("post", "http://52.76.14.6:8080/BaatnaServer/rest/wish/get?start={$start}&count=15&type=1&another_user=6", array("access_token" => $token));
if ($r->getError()) {
    echo "sorry, an error occured";
} else {
    // parse json
    //var_dump($r->getResponse());
    $js = json_decode($r->getResponse());
    $obj = $js->{"response"};
    $obj2 = $obj->wishes;
    echo json_encode($obj2);
}
开发者ID:app-ad,项目名称:Baatna-web,代码行数:29,代码来源:httprequestoffers.php

示例10: HttpRequest

<?php

$token = $_GET['tok'];
error_reporting(E_ALL);
ini_set("display_errors", "1");
require_once 'Http2.php';
$r = new HttpRequest("post", "http://52.76.14.6:8080/BaatnaServer/rest/auth/logout", array("access_token" => $token));
if ($r->getError()) {
    echo "sorry, an error occured";
} else {
    echo $r->getResponse();
}
?>


?>
开发者ID:app-ad,项目名称:Baatna-web,代码行数:16,代码来源:check.php

示例11: sendRequest

 /**
  * Sends a request to Reddit and returns the response received
  *
  * @access public
  * @param  string $verb  'GET', 'POST', ...
  * @param  string $url   'http://www.reddit.com/comments/6nw57.json'
  * @param  string $body
  * @return array
  */
 public function sendRequest($verb, $url, $body = '')
 {
     $request = new HttpRequest();
     $request->setUrl($url);
     $request->setHttpMethod($verb);
     if ($verb === 'POST' && is_array($body)) {
         foreach ($body as $name => $value) {
             $request->setPostVariable($name, $value);
         }
     }
     if ($this->sessionCookie !== null) {
         $request->setCookie('reddit_session', $this->sessionCookie);
     }
     $response = $request->getResponse();
     if (!$response instanceof HttpResponse) {
         return null;
     }
     //        $this->dumpRateInfo($response->getHeaders());
     $responseBody = $response->getBody();
     $response = json_decode($responseBody, true);
     if (isset($response['data']['modhash'])) {
         $this->modHash = $response['data']['modhash'];
     } elseif (isset($response[0]['data']['modhash'])) {
         $this->modHash = $response[0]['data']['modhash'];
     }
     return $response;
 }
开发者ID:judge2020,项目名称:ChannelBot,代码行数:36,代码来源:Reddit.php

示例12: updateFeatureCodes

 public static function updateFeatureCodes($lang, callback $callback = null)
 {
     $db = new DatabaseConnection();
     $cache = base::expand('app:/cache/geonames/');
     cb($callback, 'Downloading featurecodes', 0, 1);
     $url = self::getUrl('featureCodes_' . strtolower($lang) . '.txt');
     $req = new HttpRequest($url);
     $lstr = strtolower($lang);
     $reqs = explode("\n", $req->getResponse());
     $rows = 0;
     $ltime = 0;
     foreach ($reqs as $reql) {
         $rd = explode("\t", trim($reql) . "\t");
         if (count($rd) > 3) {
             $db->updateRow("REPLACE INTO geonames_featurecodes " . "(featurecode,lang,featurename,description) VALUES (%s,%s,%s,%s)", $rd[0], $lstr, $rd[1], $rd[2]);
             if (microtime(true) > $ltime + 1) {
                 cb($callback, 'Importing featurecodes ... ' . $rows . " records imported", 1);
                 $ltime = microtime(true);
             }
             $rows++;
         }
     }
     cb($callback, "Imported featurecodes (" . $rows . " rows)");
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:24,代码来源:geonames.php

示例13: HttpRequest

<?php

require 'class-http-request.php';
$r = new HttpRequest("get", "http://twitter.com/statuses/public_timeline.json");
if ($r->getError()) {
    echo "sorry, an error occured";
} else {
    // parse json and show tweets
    $tweets = json_decode($r->getResponse());
    var_dump($tweets);
}
开发者ID:hay,项目名称:httprequest,代码行数:11,代码来源:example.php


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