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); } }
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); } }
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); } } }
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()); } }
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++; }
<?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); }
<?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'; }