本文整理汇总了PHP中HTTP::POST方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::POST方法的具体用法?PHP HTTP::POST怎么用?PHP HTTP::POST使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP
的用法示例。
在下文中一共展示了HTTP::POST方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
private static function _execute($url, $method, $post = null)
{
$data = parse_url($url);
if (isset($data['user']) || isset($data['pass'])) {
// TODO: not yet implemented
return false;
}
if (isset($data['query'])) {
$data['fullpath'] = $data['path'] . '?' . $data['query'];
} else {
$data['fullpath'] = $data['path'];
}
switch ($data['scheme']) {
case 'http':
$HTTP = new HTTP($data['host'], isset($data['port']) ? $data['port'] : 80);
break;
case 'https':
$HTTP = new HTTP($data['host'], isset($data['port']) ? $data['port'] : 443, true);
break;
default:
return false;
break;
}
switch ($method) {
case 'GET':
return $HTTP->GET($data['fullpath']);
break;
case 'POST':
return $HTTP->POST($data['fullpath'], $post);
break;
default:
return false;
break;
}
}
示例2: _xUpdateGetInstaller
function _xUpdateGetInstaller()
{
global $C;
$post_data = array('upgrade' => true, 'version' => $_REQUEST['version'], 'key' => LIC_KEY, 'domain' => domain_from_url($C['base_url']));
require_once 'http.php';
$http = new HTTP();
if ($http->POST(URL_DOWNLOAD, $post_data)) {
if (preg_match('~X-SHA1: ([a-z0-9]+)~i', $http->response_headers, $matches)) {
$installer_file = DIR_DATA . '/install.dat';
$sha1 = $matches[1];
file_write($installer_file, $http->body);
if ($sha1 != sha1_file($installer_file)) {
file_delete($installer_file);
JSON::Error('File hash does not match, possible corrupted data. Please try again.');
} else {
JSON::Success();
}
} else {
if (preg_match('~X-Error: ([a-z0-9_]+)~i', $http->response_headers, $matches)) {
JSON::Error('Unable to locate a license for this domain');
} else {
JSON::Error('Download from jmbsoft.com failed, please try again');
}
}
} else {
JSON::Error('Unable to connect to jmbsoft.com for update: ' + $http->error);
}
}
示例3: Execute
function Execute()
{
require_once 'http.php';
$http = new HTTP();
if ($http->POST($this->url, $this->post_data)) {
if (strpos($http->body, NETWORK_SUCCESS) === 0) {
return substr($http->body, strlen(NETWORK_SUCCESS));
} else {
$this->error = substr(strip_tags($http->body), 0, 100);
return false;
}
} else {
$this->error = $http->error;
return false;
}
}
示例4: getW3Challs
private function getW3Challs($count)
{
$HTTP = new HTTP('w3challs.com');
$html = $HTTP->GET('/');
if (!$html) {
return false;
}
if (!preg_match('#<input type="hidden" name="member_token" value="(.+?)" />#', $html, $arr)) {
return false;
}
$token = $arr[1];
$html = $HTTP->POST('/profile/awe', array('changeLanguage' => 'fr', 'member_token' => $token));
if (!$html) {
return false;
}
preg_match_all('#<a href="/challenges/challenge(\\d+?)".+?title="(.+?), by (.+?) \\(Points: (\\d+?);#', $html, $arr);
$challs = array();
for ($i = 0; $i < sizeof($arr[1]); $i++) {
$challs[] = array('id' => $arr[1][$i], 'name' => $arr[2][$i], 'author' => $arr[3][$i], 'points' => $arr[4][$i]);
}
usort($challs, array('self', 'sortByID'));
$texts = array();
for ($i = 0; $i < $count; $i++) {
$texts[] = sprintf("%s by %s worth %d points ( %s )", $challs[$i]['name'], $challs[$i]['author'], $challs[$i]['points'], 'http://w3challs.com/challenges/challenge' . $challs[$i]['id']);
}
return $texts;
}
示例5: checkMD5Decrypt
private function checkMD5Decrypt($hash)
{
$HTTP = new HTTP('www.md5decrypt.org');
$html = $HTTP->GET('/');
if ($html === false) {
return false;
}
if (!preg_match('/<script>document.cookie=\'(.+?)=(.+?)\';/', $html, $arr)) {
return false;
}
$HTTP->setCookie($arr[1], $arr[2]);
$res = $HTTP->POST('/index/process', array('value' => base64_encode($hash), 'operation' => 'MD5D'));
if ($res === false) {
return false;
}
$json = json_decode($res);
if (!$json) {
return false;
}
if (!empty($json->error)) {
return false;
}
return $json->body;
}
示例6: request_result
public function request_result($data)
{
if ($data["url"][0] != "/") {
return false;
}
if ($_SERVER["HTTPS"] == "on") {
$http = new HTTPS($_SERVER["HTTP_HOST"]);
} else {
$http = new HTTP($_SERVER["HTTP_HOST"]);
}
/* Determine URL path
*/
$url = $data["url"];
if (strpos($url, "?") === false) {
$url .= "?";
} else {
$url .= "&";
}
$url .= "output=";
switch ($data["type"]) {
case "ajax":
$url .= "ajax";
break;
case "xml":
$url .= "restxml";
break;
case "json":
$url .= "restjson";
break;
default:
return false;
}
/* Restore cookies
*/
if (isset($_SESSION["apitest_cookies"])) {
if (($cookies = json_decode($_SESSION["apitest_cookies"], true)) !== null) {
foreach ($cookies as $key => $value) {
$http->add_cookie($key, $value);
}
}
}
/* Authentication
*/
if ($data["username"] != "" && $data["password"] != "") {
$auth_str = sprintf("%s:%s", $data["username"], $data["password"]);
$http->add_header("Authorization", "Basic " . base64_encode($auth_str));
}
/* Send request
*/
switch ($data["method"]) {
case "GET":
$result = $http->GET($url);
break;
case "POST":
$result = $http->POST($url, $data["postdata"]);
break;
case "PUT":
$result = $http->PUT($url, $data["postdata"]);
break;
case "DELETE":
$result = $http->DELETE($url);
break;
default:
return false;
}
/* Decode JSON result
*/
if ($result["headers"]["content-type"] == "application/json") {
$result["body"] = $this->indent_json($result["body"]);
}
/* Store cookies
*/
$_SESSION["apitest_cookies"] = json_encode($http->cookies);
return $result;
}