本文整理汇总了PHP中HttpSocket::get方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpSocket::get方法的具体用法?PHP HttpSocket::get怎么用?PHP HttpSocket::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpSocket
的用法示例。
在下文中一共展示了HttpSocket::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: graph
public function graph($objectId = 'me', $params = array())
{
if (empty($objectId)) {
return;
}
$params += array('decode' => true);
$decode = $params['decode'];
unset($params['decode']);
App::import('Core', 'HttpSocket');
$socket = new HttpSocket();
$protocol = SlConfigure::read('Api.facebook.secure') && SlConfigure::read('Sl.options.sslTransport') ? 'https' : 'http';
$result = $socket->get("{$protocol}://graph.facebook.com/{$objectId}", $this->accessToken ? $params + array('access_token' => $this->accessToken) : $params);
return $decode ? json_decode($result, true) : $result;
}
示例2: test_Censorship
/**
* test_Censorship
*
*/
public function test_Censorship()
{
$hash = $this->hash;
$to = 'to+' . $hash . '@mailback.me';
Configure::write('Postman.censorship.mode', true);
Configure::write('Postman.censorship.config', array('transport' => 'Smtp', 'from' => array('form@mailback.me' => 'from'), 'to' => $to, 'host' => 'mail.mailback.me', 'port' => 25, 'timeout' => 30, 'log' => false, 'charset' => 'utf-8', 'headerCharset' => 'utf-8'));
$message = 'Censored';
$expect = $message;
$this->email->subject('メールタイトル');
$this->email->send($expect);
sleep(15);
$url = 'http://mailback.me/to/' . $hash . '.body';
App::uses('HttpSocket', 'Network/Http');
$HttpSocket = new HttpSocket();
$results = $HttpSocket->get($url, array());
$body = trim(str_replace(array("\r\n", "\n", ' '), '', $results->body));
$message = trim(str_replace(array("\r\n", "\n", ' '), '', $message));
$this->assertIdentical($results->code, '200');
$this->assertIdentical($body, $message);
// CC
$ccUrl = 'http://mailback.me/to/unknown-cc-' . $hash . '.body';
$results = $HttpSocket->get($ccUrl, array());
$this->assertContains('404', $results->body);
// BCC
$bccUrl = 'http://mailback.me/to/unknown-bcc-' . $hash . '.body';
$results = $HttpSocket->get($bccUrl, array());
$this->assertContains('404', $results->body);
}
示例3: download
function download()
{
$result = array('success' => true, 'error' => null);
$home = Configure::read('20Couch.home');
App::import('Core', array('HttpSocket', 'File'));
$Http = new HttpSocket();
$Setting = ClassRegistry::init('Setting');
$url = sprintf('%s/registrations/direct/%s/' . Configure::read('Update.file'), $home, $Setting->find('value', 'registration_key'));
$latest = $Http->get($url);
if ($latest === false || $Http->response['status']['code'] != 200) {
if ($Http->response['status']['code'] == 401) {
$msg = 'Invalid registration key';
} else {
$msg = 'Unable to retrieve latest file from ' . $home;
}
$this->log($url);
$this->log($Http->response);
$result = array('success' => false, 'error' => $msg);
$this->set('result', $result);
return;
}
$File = new File(TMP . Configure::read('Update.file'), false);
$File->write($latest);
$File->close();
$latestChecksum = trim($Http->get($home . '/checksum'));
$yourChecksum = sha1_file(TMP . Configure::read('Update.file'));
if ($yourChecksum != $latestChecksum) {
$result = array('success' => false, 'error' => 'Checksum doesn\'t match (' . $yourChecksum . ' vs ' . $latestChecksum . ')');
$this->set('result', $result);
return;
}
$result = array('success' => true, 'error' => null);
$this->set('result', $result);
}
示例4: decrypt
public function decrypt()
{
while (empty($md5)) {
$md5 = $this->in('Ingrese el Hash a buscar');
}
$HttpSocket = new HttpSocket();
$md5 = trim($md5);
if (strlen($md5) !== 32) {
return $this->out('Hash invalido');
}
$matches = array();
$html = $HttpSocket->get($this->_url);
$pattern = '/<input type="hidden" name="a" value="(.*)">/Uis';
preg_match_all($pattern, $html->body, $matches, PREG_SET_ORDER);
if (empty($matches[0][1])) {
return $this->out('El servidor no responde');
}
$a = $matches[0][1];
$rest = $this->postDataViaCurl($HttpSocket, $md5, $a);
do {
$this->out('..');
sleep(1);
} while ($rest->code === null);
$returnArray = array();
$pattern2 = '/Found (.*) <b>(.*)<\\/b><\\/span>/Uis';
preg_match_all($pattern2, $rest, $returnArray, PREG_SET_ORDER);
if (empty($returnArray[0][2])) {
return $this->out('El servidor no responde');
}
$nt = trim(strip_tags($returnArray[0][2]));
if (empty($nt)) {
return false;
}
$this->out('Contraseña desencriptada: <info>' . $nt . '</info>');
}
示例5: Xml
/**
* Perform the request to AWS
*
* @return mixed array of the resulting request or false if unable to contact server
* @access private
*/
function __request()
{
$this->_request = $this->__signQuery();
$retval = $this->Http->get($this->_request);
$retval = Set::reverse(new Xml($retval));
return $retval;
}
示例6: getStatus
public function getStatus($code)
{
App::import('Core', 'HttpSocket');
$HttpSocket = new HttpSocket(array('timeout' => $this->timeout));
$response = $HttpSocket->get($this->pgURI . $code, "email={$__config['email']}&token={$__config['token']}");
return $this->__status($response);
}
示例7: maestro
public function maestro($key = null)
{
if ($key != 'secret') {
die('sorry');
}
App::uses('HttpSocket', 'Network/Http');
$httpSocket = new HttpSocket();
$yesterday = date("Y-m-d H:i:s", strtotime("-1 day"));
// print_r($yesterday);
// die;
$products = $this->Product->find('all', array('recursive' => -1, 'conditions' => array('Product.user_id' => 11, 'Product.active' => 1, 'Product.stock_updated <' => $yesterday), 'order' => 'RAND()', 'limit' => 20));
foreach ($products as $product) {
//sleep(1);
$response = $httpSocket->get('https://www.maestrolico.com/api/checkstockstatus.asp?distributorid=117&productid=' . $product['Product']['vendor_sku']);
echo '<br /><hr><br />';
echo $product['Product']['name'] . ' - ' . $product['Product']['vendor_sku'];
echo '<br /><br />';
debug($response['body']);
$update = explode('|', $response['body']);
debug($update);
debug(date('H:i:s'));
$data['Product']['id'] = $product['Product']['id'];
$data['Product']['stock'] = $update[1];
$data['Product']['stock_updated'] = date('Y-m-d H:i:s');
$this->Product->save($data, false);
}
die('end');
}
示例8: array
function admin_callback()
{
$endpoint = $this->request->query['openid_op_endpoint'];
$query = array();
$keys = array('openid.ns', 'openid.mode', 'openid.op_endpoint', 'openid.response_nonce', 'openid.return_to', 'openid.assoc_handle', 'openid.signed', 'openid.sig', 'openid.identity', 'openid.claimed_id', 'openid.ns.ext1', 'openid.ext1.mode', 'openid.ext1.type.firstname', 'openid.ext1.value.firstname', 'openid.ext1.type.email', 'openid.ext1.value.email', 'openid.ext1.type.lastname', 'openid.ext1.value.lastname');
foreach ($keys as $key) {
$underscoreKey = str_replace('.', '_', $key);
if (isset($this->params['url'][$underscoreKey])) {
$query[$key] = $this->params['url'][$underscoreKey];
}
}
$query['openid.mode'] = 'check_authentication';
$Http = new HttpSocket();
$response = $Http->get($this->request->query['openid_op_endpoint'] . '?' . http_build_query($query));
if (strpos($response, 'is_valid:true') === false) {
return $this->redirect($this->Auth->loginAction);
}
$url = $this->params['url'];
if (isset($url['openid_mode']) && $url['openid_mode'] == 'cancel') {
return $this->redirect($this->Auth->redirect());
}
$user = array('id' => $url['openid_ext1_value_email'], 'name' => $url['openid_ext1_value_firstname'] . ' ' . $url['openid_ext1_value_lastname'], 'email' => $url['openid_ext1_value_email']);
$this->__callback($user);
$this->Session->write(AuthComponent::$sessionKey, $user);
$this->set('redirect', $this->Auth->redirect());
}
示例9: __request
/**
* Perform the request to AWS
*
* @return mixed array of the resulting request or false if unable to contact server
*/
private function __request()
{
$this->_request = $this->__signQuery();
$this->__requestLog[] = $this->_request;
$retval = $this->Http->get($this->_request);
return Set::reverse(new Xml($retval));
}
示例10: index
function index()
{
App::import('Core', 'HttpSocket');
$HttpSocketPr = new HttpSocket();
// $results = $HttpSocketPr->get('https://www.google.com.mx/search', 'q=php');
$HttpSocketPr->get('http://anonymouse.org/cgi-bin/anon-www.cgi/http://187.141.67.234/projections/users/login');
// returns html for Google's search results for the query "cakephp"
if (!empty($HttpSocketPr->response['cookies']['CAKEPHP']['path']) and $HttpSocketPr->response['cookies']['CAKEPHP']['path'] === '/projections') {
debug($HttpSocketPr->response['cookies']);
var_dump('Projections External site is OK');
} else {
var_dump('Projections External site is Down');
}
$HttpSocketGst = new HttpSocket();
$HttpSocketGst->get('http://anonymouse.org/cgi-bin/anon-www.cgi/http://187.141.67.234/gst/users/login');
if (!empty($HttpSocketGst->response['cookies']['CAKEPHP']['path']) and $HttpSocketGst->response['cookies']['CAKEPHP']['path'] === '/gst') {
debug($HttpSocketGst->response['cookies']);
var_dump('Gst External site is OK');
} else {
var_dump('Gst External site is Down');
}
// $HttpSocketFm = new HttpSocket();
// $HttpSocketFm->get('http://localhost/smb/class/filemanager/filemanager.php');
//
// $this->set('fm',$HttpSocketFm->response['body']);
$this->FieldView->recursive = 0;
$this->set('fieldViews', $this->paginate());
}
示例11: fetch
/**
* fetches url with curl if available
* fallbacks: cake and php
* note: expects url with json encoded content
* @access private
**/
public function fetch($url, $agent = 'cakephp http socket lib')
{
if ($this->use['curl'] && function_exists('curl_init')) {
$this->debug = 'curl';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status != '200') {
$this->setError('Error ' . $status);
return false;
}
return $response;
} elseif ($this->use['cake'] && App::import('Core', 'HttpSocket')) {
$this->debug = 'cake';
$HttpSocket = new HttpSocket(array('timeout' => 5));
$response = $HttpSocket->get($url);
if (empty($response)) {
//TODO: status 200?
return false;
}
return $response;
} elseif ($this->use['php'] || true) {
$this->debug = 'php';
$response = file_get_contents($url, 'r');
//TODO: status 200?
if (empty($response)) {
return false;
}
return $response;
}
}
示例12: main
function main()
{
App::import('HttpSocket');
$site = isset($this->args['0']) ? $this->args['0'] : null;
while (empty($site)) {
$site = $this->in("What site would you like to crawl?");
if (!empty($site)) {
break;
}
$this->out("Try again.");
}
$Socket = new HttpSocket();
$links = array();
$start = 0;
$num = 100;
do {
$r = $Socket->get('http://www.google.com/search', array('hl' => 'en', 'as_sitesearch' => $site, 'num' => $num, 'filter' => 0, 'start' => $start));
if (!preg_match_all('/href="([^"]+)" class="?l"?/is', $r, $matches)) {
die($this->out('Error: Could not parse google results'));
}
$links = array_merge($links, $matches[1]);
$start = $start + $num;
} while (count($matches[1]) >= $num);
$links = array_unique($links);
$this->out(sprintf('-> Found %d links on google:', count($links)));
$this->hr();
$this->out(join("\n", $links));
}
示例13: _get
/**
* _get()
*
* @param mixed $url
* @param mixed $params
* @return string
*/
protected function _get($url, $params)
{
$Socket = new HttpSocket();
$response = $Socket->get($url, $params);
//$file = TMP . Inflector::slug($url) . '.json';
//file_put_contents($file, $response->body);
return isset($response->body) ? $response->body : '';
}
示例14: request_view
public function request_view($id)
{
$link = Router::url('/', true) . 'rest_posts/' . $id . '.json';
$data = null;
$httpSocket = new HttpSocket();
$response = $httpSocket->get($link, $data);
$this->set('response_code', $response->code);
$this->set('response_body', $response->body);
$this->render('/Client/request_response');
}
示例15: request_view
public function request_view($id)
{
// remotely post the information to the server
$link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . 'rest_tasks/' . $id . '.json';
$data = null;
$httpSocket = new HttpSocket();
$response = $httpSocket->get($link, $data);
$this->set('response_code', $response->code);
$this->set('response_body', $response->body);
$this->render('/Client/request_response');
}