本文整理汇总了PHP中Snoopy::submit方法的典型用法代码示例。如果您正苦于以下问题:PHP Snoopy::submit方法的具体用法?PHP Snoopy::submit怎么用?PHP Snoopy::submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Snoopy
的用法示例。
在下文中一共展示了Snoopy::submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wikiLogin
function wikiLogin()
{
global $login;
global $wikilogin;
global $snoopy;
global $wikiapi_url;
while (!$login) {
$wikilogin['action'] = 'login';
$wikilogin['lgname'] = trim(ask('wiki user name'));
$wikilogin['lgpassword'] = getPassword('wikis');
$wikilogin['format'] = 'php';
if (!$snoopy instanceof Snoopy) {
$snoopy = new Snoopy();
}
if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
I2CE::raiseError("Could not log in to {$wikiapi_url}");
continue;
}
$res = unserialize($snoopy->results);
if (array_key_exists('error', $res)) {
I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
continue;
}
if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
I2CE::raiseError("Error logging in:" . print_r($res, true));
continue;
}
if ($res['login']['result'] == 'NeedToken' && array_key_exists('token', $res['login']) && $res['login']['token']) {
$wikilogin['lgtoken'] = $res['login']['token'];
$snoopy->setcookies();
if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
I2CE::raiseError("Could not log in to {$wikiapi_url}");
continue;
}
$res = unserialize($snoopy->results);
if (array_key_exists('error', $res)) {
I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
continue;
}
if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
I2CE::raiseError("Error logging in");
continue;
}
}
if ($res['login']['result'] != 'Success') {
I2CE::raiseError("No success logging in:" . print_r($res, true));
continue;
}
I2CE::raiseError("Logged into {$wikiapi_url} as " . $wikilogin['lgname']);
$snoopy->setcookies();
$login = true;
}
return $login;
}
示例2: sso_user_login
function sso_user_login($username, $password)
{
global $CFG, $SESSION;
include $CFG->libdir . '/snoopy/Snoopy.class.inc';
if (empty($CFG->hivehost)) {
return false;
// Hive config variables not configured yet
}
/// Set up Snoopy
$snoopy = new Snoopy();
$submit_url = $CFG->hiveprotocol . '://' . $CFG->hivehost . ':' . $CFG->hiveport . '' . $CFG->hivepath;
$submit_vars['HIVE_UNAME'] = $username;
$submit_vars['HIVE_UPASS'] = $password;
$submit_vars['HIVE_ENDUSER'] = $username;
$submit_vars['HIVE_REQ'] = '2112';
$submit_vars['HIVE_REF'] = 'hin:hive@API Login 3';
$submit_vars['HIVE_RET'] = 'ORG';
$submit_vars['HIVE_REM'] = '';
$submit_vars['HIVE_PROD'] = '0';
$submit_vars['HIVE_USERIP'] = getremoteaddr();
/// We use POST to call Hive with a bit more security
$snoopy->submit($submit_url, $submit_vars);
/// Extract HIVE_SESSION from headers
foreach ($snoopy->headers as $header) {
if (strpos($header, 'HIVE_SESSION=') !== false) {
$header = explode('HIVE_SESSION=', $header);
if (count($header) > 1) {
$cookie = explode(';', $header[1]);
$cookie = $cookie[0];
$SESSION->HIVE_SESSION = $cookie;
return true;
}
}
}
/// Try again with the guest username and password
$submit_vars['HIVE_UNAME'] = $CFG->hiveusername;
$submit_vars['HIVE_UPASS'] = $CFG->hivepassword;
$submit_vars['HIVE_ENDUSER'] = $CFG->hiveusername;
$snoopy->submit($submit_url, $submit_vars);
foreach ($snoopy->headers as $header) {
if (strpos($header, 'HIVE_SESSION=') !== false) {
$header = explode('HIVE_SESSION=', $header);
if (count($header) > 1) {
$cookie = explode(';', $header[1]);
$cookie = $cookie[0];
$SESSION->HIVE_SESSION = $cookie;
return true;
}
}
}
return false;
// No cookie found
}
示例3: renew
private function renew()
{
$postArray = array('action' => 'Renew', 'book_barcode' => preg_match('/\\//', $this->bookID) ? $this->bookID : urlencode($this->bookID), 'department_id' => $this->deptID, 'library_id' => $this->libraryID);
print_r($postArray);
$studentData;
$url = 'http://202.197.232.4:8081/opac_two/reader/jieshuxinxi.jsp';
$snoopy = new Snoopy();
$snoopy->rawheaders['Cookie'] = $this->cookies;
$snoopy->submit($url, $postArray);
if ($snoopy->status != 200) {
return $this->setMsg(3);
}
$data = iconv('gbk', 'utf-8', $snoopy->results);
if (preg_match('/续借成功/', $data)) {
return $this->setMsg(0);
} else {
if (preg_match('/现已续借/', $data)) {
return $this->setMsg(6);
} else {
if (preg_match('/读取续借规则错误/', $data)) {
return $this->setMsg(7);
} else {
return $this->setMsg(4);
}
}
}
}
示例4: socialdiscuss_http_post
function socialdiscuss_http_post($link, $body)
{
if (!$link) {
return array(500, 'Invalid Link');
}
require_once ABSPATH . WPINC . '/class-snoopy.php';
$snoop = new Snoopy();
if ($snoop->submit($link, $body)) {
if (strpos($snoop->response_code, '200')) {
$response = $snoop->results;
return array(200, $response);
}
}
if (!class_exists('WP_Http')) {
include_once ABSPATH . WPINC . '/class-http.php';
}
if (!class_exists('WP_Http')) {
return array(500, $snoop->response_code);
}
$request = new WP_Http();
$response_full = $request->request($link, array('method' => 'POST', 'body' => $body, 'headers' => $headers));
if (isset($response_full->errors)) {
return array(500, 'Unknown Error');
}
$response_code = $response_full['response']['code'];
if ($response_code === 200) {
$response = $response_full['body'];
return array($response_code, $response);
}
$response_msg = $response_full['response']['message'];
return array($response_code, $response_msg);
}
示例5: getName
/**
* 学校验证
* @method getName
* @param [type] $stu_number [学号]
* @param [type] $pwd [密码]
* @return [string/bool] [验证成功返回姓名,验证失败返回false]
* @author NewFuture[newfuture@yunyin.org]
*/
function getName($stu_number, $pwd)
{
/*基本信息*/
$ACTION_URL = 'http://jw.tifert.edu.cn/2003/Logon.do?method=logon';
$INFO_URL = 'http://jw.tifert.edu.cn/2003/framework/main.jsp';
$SUCCESS_KEY = '<script language=\'javascript\'>window.location.href=\'http://jw.tifert.edu.cn/2003/framework/main.jsp\';</script>';
$START_FALG = '当前用户:';
$END_FLAG = '</td>';
$snoopy = new Snoopy();
/*设置请求头,非必需 */
$snoopy->referer = 'http://jw.tifert.edu.cn/2003/';
$snoopy->rawheaders['Pragma'] = 'no-cache';
$snoopy->rawheaders['X_FORWARDED_FOR'] = get_client_ip();
/*用户学号和密码*/
$input['USERNAME'] = $stu_number;
$input['PASSWORD'] = $pwd;
//模拟登陆
$snoopy->submit($ACTION_URL, $input);
$result = $snoopy->results;
//登录结果页面
if (strpos($result, $SUCCESS_KEY) === false) {
/*验证失败*/
return false;
} else {
/*登录成功,保存cookie信息页面抓取信息*/
$snoopy->setcookies();
$snoopy->fetch($INFO_URL);
$results = $snoopy->results;
$s = strpos($results, $START_FALG) + strlen($START_FALG);
//起始位置
$e = strpos($results, $END_FLAG, $s);
$name = substr($results, $s, $e - $s);
return trim($name);
}
}
示例6: post
/**
* @param $url
* @param $post_data
* @return mixed|null
*/
public static function post($url, array $post_data)
{
//因线上PHP版本为5.5所以移到此处
$host2 = array('account/register.json', 'bankBranch/select/branch.json', 'account/bank/list.json', 'account/bankcard/bind.json', 'user/identity/auth.json', 'loginRest/getUserCenterInfo.json', 'account/bankcard/modify.json');
$post_data['_ts'] = time();
$post_data['token'] = self::TOKEN;
$post_data['user_id'] = isset($post_data['user_id']) ? $post_data['user_id'] : Yii::app()->user->getId();
if ($url != 'account/bankcard/bind.json' && $url != 'loginRest/getUserCenterInfo.json' && $url != 'account/bankcard/modify.json') {
$post_data['access_from'] = 'admin';
}
$sdata = array();
foreach ($post_data as $key => $value) {
$sdata[$key] = trim($value);
}
try {
$_snoopy = new Snoopy();
$data = null;
if (in_array($url, $host2)) {
$furl = Yii::app()->params['back_host2'] . $url;
} else {
$furl = Yii::app()->params['back_host'] . $url;
}
$_snoopy->submit($furl, $sdata);
if ($_snoopy->results != '') {
$data = json_decode($_snoopy->results, true);
}
// var_dump($furl, $sdata, $data);
self::json_log($_snoopy->results);
return $data;
} catch (Exception $ex) {
return null;
}
return null;
}
示例7: init
private function init()
{
$snoopy = new Snoopy();
//Get Viewstate First
$snoopy->fetch('http://202.197.224.66:8084/pyxx/login.aspx');
if ($snoopy->status != 200) {
return $this->setMsg(3);
}
if (preg_match('/value="(.*?)"/', $snoopy->results, $viewstate)) {
$this->postArray['__VIEWSTATE'] = $viewstate[1];
} else {
return $this->setMsg(3);
}
//Set SessionId
$snoopy->cookies['ASP.NET_SessionId'] = $this->sessionId;
//Submit Form
$snoopy->submit('http://202.197.224.66:8084/pyxx/login.aspx', $this->postArray);
if ($snoopy->status != 200) {
return $this->setMsg(3);
}
if (preg_match('/密码错误/', $snoopy->results)) {
return $this->setMsg(1);
}
if (!preg_match('/html/', $snoopy->results)) {
return $this->setMsg(4);
}
//Get Student Info
$snoopy->fetch('http://202.197.224.66:8084/pyxx/grgl/xsinfoshow.aspx');
if ($snoopy->status != 200) {
return $this->setMsg(3);
}
//echo $snoopy->results;
if (!preg_match('/个人基本信息/', $snoopy->results)) {
return $this->setMsg(4);
}
if (preg_match('/<span id="lblxm1">(.*?)<\\/span>/', $snoopy->results, $matches)) {
$studentData['name'] = urlencode($matches[1]);
} else {
return $this->setMsg(4);
}
if (preg_match('/<span id="lblxb">(.*?)<\\/span>/', $snoopy->results, $matches)) {
$studentData['sex'] = urlencode($matches[1]);
}
if (preg_match('/<span id="lblcsrq">(.*?)<\\/span>/', $snoopy->results, $matches)) {
$studentData['date_of_birth'] = urlencode($matches[1]);
}
if (preg_match('/<span id="lbljtdq">(.*?)<\\/span>/', $snoopy->results, $matches)) {
$studentData['location'] = urlencode($matches[1]);
}
if (preg_match('/<span id="lblyxzy">(.*?)<\\/span>/', $snoopy->results, $matches)) {
$arr = explode('_', $matches[1]);
$studentData['college'] = urlencode($arr[0]);
$studentData['major'] = urlencode($arr[1]);
}
$this->studentData = $studentData;
return $this->setMsg(0);
}
示例8: checkInfo
private function checkInfo()
{
$snoopy = new Snoopy();
$postArray = array('username' => $this->sid, 'password' => $this->password, 'identity' => 'student', 'role' => 1);
$snoopy->submit($this->checkUrl, $postArray);
$this->processCookies($snoopy->headers);
$snoopy->rawheaders['Cookie'] = $this->cookies;
$data = iconv('gbk', 'utf-8', $snoopy->results);
$this->checkIfError($data);
$this->getName($snoopy, $postArray);
}
示例9: upload
function upload()
{
$snoopy = new Snoopy();
$submit = self::img_url . "post.php";
$file = $this->uploadfile;
$data["type"] = $this->type;
$data["filename"] = $this->file;
$data["path"] = $this->path;
$snoopy->_submit_type = "multipart/form-data";
$snoopy->submit($submit, $data, $file);
return $snoopy->results;
}
示例10: executeDefaultOp
function executeDefaultOp()
{
error_reporting(E_ERROR);
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $_ENV['HTTP_REFERER'];
if (!$referer) {
exit;
}
if (strpos($referer, $this->getUrlBase()) === false) {
exit;
}
if (empty($_REQUEST['geoop'])) {
exit;
}
include "../../class/snoopy.php";
$snoopy = new Snoopy();
//$snoopy->proxy_host='proxy.host.com';
//$snoopy->proxy_port='8080';
$snoopy->agent = 'XOOPS MyGmap Module';
$postArray = array();
if ($_REQUEST['geoop'] == 'csis') {
$postArray['addr'] = mb_convert_encoding(urldecode($_REQUEST['addr']), 'EUC-JP', 'auto');
$postArray['series'] = $_REQUEST['series'];
$postArray['geosys'] = 'world';
$postArray['charset'] = 'x-euc-jp';
$snoopy->submit("http://geocode.csis.u-tokyo.ac.jp/cgi-bin/simple_geocode.cgi", $postArray);
} else {
if ($_REQUEST['geoop'] == 'invgeo') {
$postArray['lat'] = floatval($_REQUEST['lat']);
$postArray['lon'] = floatval($_REQUEST['lon']);
$postArray['format'] = 'simple';
$snoopy->submit("http://nishioka.sakura.ne.jp/google/ws.php", $postArray);
}
}
header('Content-type: application/xml');
echo $snoopy->results;
}
示例11: defensio_post
function defensio_post($action, $args = null)
{
global $defensio_conf;
// Use snoopy to post
require_once 'lib/class-snoopy.php';
$snoopy = new Snoopy();
$snoopy->read_timeout = $defensio_conf['post_timeout'];
// Supress the possible fsock warning
@$snoopy->submit(defensio_url_for($action, $defensio_conf['key']), $args, array());
// Defensio will return 200 nomally, 401 on authentication failure, anything else is unexpected behaivour
if ($snoopy->status == 200 or $snoopy->status == 401) {
return $snoopy->results;
} else {
return false;
}
}
示例12: Red_Enviar
function Red_Enviar($telefono, $mensaje, $firma)
{
$snoopy = new Snoopy();
// Opciones de Snoopy (Mensajitos se muestra como IExplore 6.0)
// Esto es por las paginas que bloquean a navegadores que no
// sean Internet Explorer
$snoopy->agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
// URL referente:
$snoopy->referer = "http://red.com.sv/redsms/index.php";
// URL para mensajes de Red (Intelfon)
$submit_url = "http://sms.red.com.sv:13013/cgi-bin/sendsms";
$submit_vars["to"] = $telefono;
$submit_vars["text"] = $mensaje . $firma;
$submint_vars["Submit"] = $Enviar;
$snoopy->submit($submit_url, $submit_vars);
return true;
}
示例13: Snoopy
function send_request($job)
{
var_dump("scorpio");
include_once APPPATH . 'third_party/snoopy.php';
$snoopy = new Snoopy();
$data = json_decode($job->workload());
$method = $data->method;
$url = $data->url;
$params = $data->params;
${$method} = array();
foreach ($params as $key => $value) {
${$method}[$key] = $value;
}
$snoopy->submit($url, ${$method});
$result = $snoopy->results;
return $result;
}
示例14: find_lms_user
function find_lms_user($installid, $username, $signature, $confirmaction = null, $firstname = null, $lastname = null, $email = null)
{
global $CFG;
// find this host from the installid
if (empty($CFG->lmshosts) || !is_array($CFG->lmshosts) || !array_key_exists($installid, $CFG->lmshosts)) {
return LMS_NO_SUCH_HOST;
}
$host = $CFG->lmshosts[$installid];
// validate our md5 hash
if ($confirmaction == 'signupconfirmation') {
$stringtohash = $installid . '|' . $username . '|' . $firstname . '|' . $lastname . '|' . $email . '|' . $host['token'];
} else {
$stringtohash = $installid . '|' . $username . '|' . $host['token'];
// firstname, lastname and email cannot be relied upon not to change
// so we only want to add them to the hash on signup, not for auth or anything else.
}
$checksig = md5($stringtohash);
if ($checksig != $signature) {
return LMS_INVALID_HASH;
}
// if we have an ip address, check it.
if (array_key_exists('networkaddress', $host) && empty($confirmaction)) {
if (!address_in_subnet(getremoteaddr(), $host['networkaddress'])) {
return LMS_INVALID_NETWORK;
}
}
if (!empty($confirmaction) && !empty($host['confirmurl'])) {
$client = new Snoopy();
$client->agent = LMS_SNOOPY_USER_AGENT;
$client->read_timeout = 5;
$client->use_gzip = true;
$postdata = array('action' => $confirmaction, 'username' => $username, 'signature' => $signature);
@$client->submit($host['confirmurl'], $postdata);
if ($client->results != 'OK') {
return clean_param($client->results, PARAM_CLEAN);
}
}
// find our user (we only want to check username and installid, the others could potentially change..
if (!($user = get_record_sql('SELECT u.* FROM ' . $CFG->prefix . 'users u
JOIN ' . $CFG->prefix . 'users_alias ua ON ua.user_id = u.ident
WHERE ua.installid = ? AND ua.username = ?', array($installid, $username)))) {
return LMS_NO_SUCH_USER;
}
return $user;
}
示例15: explode
function send_trackbacks($id, $trackbacks)
{
global $tikilib;
// Split to get each URI
$tracks = explode(',', $trackbacks);
$ret = array();
// Foreach URI
$post_info = $this->get_post($id);
$blog_info = $this->get_blog($post_info['blogId']);
//Build uri for post
$parts = parse_url($_SERVER['REQUEST_URI']);
$uri = $tikilib->httpPrefix() . str_replace('tiki-blog_post', 'tiki-view_blog_post', $parts['path']) . '?postId=' . $id . '&blogId=' . $post_info['blogId'];
include "lib/snoopy/Snoopy.class.php";
$snoopy = new Snoopy();
foreach ($tracks as $track) {
@($fp = fopen($track, 'r'));
if ($fp) {
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 32767);
}
fclose($fp);
preg_match("/trackback:ping=(\"|\\'|\\s*)(.+)(\"|\\'\\s)/", $data, $reqs);
if (!isset($reqs[2])) {
return $ret;
}
@($fp = fopen($reqs[2], 'r'));
if ($fp) {
fclose($fp);
$submit_url = $reqs[2];
$submit_vars["url"] = $uri;
$submit_vars["blog_name"] = $blog_info['title'];
$submit_vars["title"] = $post_info['title'] ? $post_info['title'] : date("d/m/Y [h:i]", $post_info['created']);
$submit_vars["title"] .= ' ' . tra('by') . ' ' . $post_info['user'];
$submit_vars["excerpt"] = substr($post_info['data'], 0, 200);
$snoopy->submit($submit_url, $submit_vars);
$back = $snoopy->results;
if (!strstr('<error>1</error>', $back)) {
$ret[] = $track;
}
}
}
}
return $ret;
}