本文整理汇总了PHP中HttpRequest::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpRequest::getError方法的具体用法?PHP HttpRequest::getError怎么用?PHP HttpRequest::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::getError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例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);
}
}
示例3: 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);
}
}
}
示例4: 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());
}
}
示例5: die
require 'class-http-request.php';
// Get query or die
$query = $argv[1];
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++;
}
示例6: 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);
}
示例7: HttpRequest
<?php
//echo $access_token;
//$access_token="68474014519902762";
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/messaging/get", array("access_token" => $access_token, "client_id" => "bt_android_client", "app_type" => "bt_android"));
if ($r->hasError()) {
echo $r->getError();
echo "sorry, an error occured";
} else {
// parse json
$js = json_decode($r->getResponse());
$response = $js->{"response"};
$msg = $response->{"messages"};
$nam = array();
foreach ($msg as $m) {
$obj = $m->{"message"};
$wish = $obj->wish;
$user = $obj->user;
$u2 = $user->user;
$name = $u2->user_name;
$id = $u2->user_id;
array_push($nam, array('name' => $name, 'id' => $id));
// echo $name;
}
include 'messview.php';
}