当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP::post方法代码示例

本文整理汇总了PHP中HTTP::post方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::post方法的具体用法?PHP HTTP::post怎么用?PHP HTTP::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP的用法示例。


在下文中一共展示了HTTP::post方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logout

 public static function logout($sessionID)
 {
     self::loadConfig();
     $url = self::$config['syncURLPrefix'] . "logout";
     $response = HTTP::post($url, array("version" => self::$config['apiVersion'], "sessionid" => $sessionID));
     self::checkResponse($response);
     $xml = new SimpleXMLElement($response->getBody());
     if (!$xml->loggedout) {
         throw new Exception("Error logging out");
     }
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:11,代码来源:sync.inc.php

示例2: __call

 public function __call($method, $args)
 {
     $url = (defined('PHPFOX_API_URL') ? PHPFOX_API_URL : 'http://api.phpfox.com/') . $method;
     $Http = new HTTP($url);
     $Http->auth($this->_id, $this->_key);
     if (\Phpfox::isTrial()) {
         $Http->header('PHPFOX_IS_TRIAL', '1');
     }
     $Http->using(['domain' => \Phpfox::getParam('core.path')]);
     $Http->using(['version' => \Phpfox::VERSION]);
     foreach ($args as $key => $value) {
         if (is_string($value)) {
             // $value = [$key => $value];
         }
         $Http->using($value);
     }
     return $Http->post();
 }
开发者ID:nima7r,项目名称:phpfox-dist,代码行数:18,代码来源:Home.php

示例3: testAddFileClientZip

 public function testAddFileClientZip()
 {
     API::userClear(self::$config['userID']);
     $auth = array('username' => self::$config['username'], 'password' => self::$config['password']);
     // Get last storage sync
     $response = API::userGet(self::$config['userID'], "laststoragesync?auth=1", array(), $auth);
     $this->assert404($response);
     $xml = API::createItem("book", false, $this);
     $data = API::parseDataFromItemEntry($xml);
     $key = $data['key'];
     $fileContentType = "text/html";
     $fileCharset = "UTF-8";
     $fileFilename = "file.html";
     $fileModtime = time();
     $xml = API::createAttachmentItem("imported_url", $key, $this);
     $data = API::parseDataFromItemEntry($xml);
     $key = $data['key'];
     $etag = $data['etag'];
     $json = json_decode($data['content']);
     $json->contentType = $fileContentType;
     $json->charset = $fileCharset;
     $json->filename = $fileFilename;
     $response = API::userPut(self::$config['userID'], "items/{$key}?key=" . self::$config['apiKey'], json_encode($json), array("Content-Type: application/json", "If-Match: {$etag}"));
     $this->assert200($response);
     // Get file info
     $response = API::userGet(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1&info=1", array(), $auth);
     $this->assert404($response);
     $zip = new ZipArchive();
     $file = "work/{$key}.zip";
     if ($zip->open($file, ZIPARCHIVE::CREATE) !== TRUE) {
         throw new Exception("Cannot open ZIP file");
     }
     $zip->addFromString($fileFilename, self::getRandomUnicodeString());
     $zip->addFromString("file.css", self::getRandomUnicodeString());
     $zip->close();
     $hash = md5_file($file);
     $filename = $key . ".zip";
     $size = filesize($file);
     $fileContents = file_get_contents($file);
     // Get upload authorization
     $response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", $this->implodeParams(array("md5" => $hash, "filename" => $filename, "filesize" => $size, "mtime" => $fileModtime, "zip" => 1)), array("Content-Type: application/x-www-form-urlencoded"), $auth);
     $this->assert200($response);
     $this->assertContentType("application/xml", $response);
     $xml = new SimpleXMLElement($response->getBody());
     self::$toDelete[] = "{$hash}/{$filename}";
     $boundary = "---------------------------" . rand();
     $postData = "";
     foreach ($xml->params->children() as $key => $val) {
         $postData .= "--" . $boundary . "\r\nContent-Disposition: form-data; " . "name=\"{$key}\"\r\n\r\n{$val}\r\n";
     }
     $postData .= "--" . $boundary . "\r\nContent-Disposition: form-data; " . "name=\"file\"\r\n\r\n" . $fileContents . "\r\n";
     $postData .= "--" . $boundary . "--";
     // Upload to S3
     $response = HTTP::post((string) $xml->url, $postData, array("Content-Type: multipart/form-data; boundary=" . $boundary));
     $this->assert201($response);
     //
     // Register upload
     //
     $response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", "update=" . $xml->key . "&mtime=" . $fileModtime, array("Content-Type: application/x-www-form-urlencoded"), $auth);
     $this->assert204($response);
     // Verify attachment item metadata
     $response = API::userGet(self::$config['userID'], "items/{$data['key']}?key=" . self::$config['apiKey'] . "&content=json");
     $xml = API::getXMLFromResponse($response);
     $json = json_decode(array_shift($xml->xpath('/atom:entry/atom:content')));
     $this->assertEquals($hash, $json->md5);
     $this->assertEquals($fileFilename, $json->filename);
     $this->assertEquals($fileModtime, $json->mtime);
     $response = API::userGet(self::$config['userID'], "laststoragesync?auth=1", array(), array('username' => self::$config['username'], 'password' => self::$config['password']));
     $this->assert200($response);
     $mtime = $response->getBody();
     $this->assertRegExp('/^[0-9]{10}$/', $mtime);
     // File exists
     $response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", $this->implodeParams(array("md5" => $hash, "filename" => $filename, "filesize" => $size, "mtime" => $fileModtime + 1000, "zip" => 1)), array("Content-Type: application/x-www-form-urlencoded"), $auth);
     $this->assert200($response);
     $this->assertContentType("application/xml", $response);
     $this->assertEquals("<exists/>", $response->getBody());
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:77,代码来源:FileTest.php

示例4: post

 public static function post($url, $data, $headers = array(), $auth = false)
 {
     $url = self::$config['apiURLPrefix'] . $url;
     if (self::$apiVersion) {
         $headers[] = "Zotero-API-Version: " . self::$apiVersion;
     }
     if (!$auth && self::$apiKey) {
         $headers[] = "Authorization: Bearer " . self::$apiKey;
     }
     $response = HTTP::post($url, $data, $headers, $auth);
     return $response;
 }
开发者ID:selenus,项目名称:dataserver,代码行数:12,代码来源:api3.inc.php

示例5: getUserIdsFromPhotoId

 /**
  * Takes a photo ID, returns owner's NSID and path_alias
  * (the username which appears in the URL), if available.
  * @param string $flickrPhotoId
  * @return array an array containing the NSID first and the path_alias second. The path_alias
  *     is not guaranteed to exist, in which case the array will have a single item;
  *     if there is no such photo (or some other error happened), the array will be empty.
  */
 protected function getUserIdsFromPhotoId($flickrPhotoId)
 {
     $userIds = array();
     $params = array('postData' => array('method' => 'flickr.photos.getInfo', 'api_key' => $this->flickrApiKey, 'photo_id' => $flickrPhotoId, 'format' => 'json', 'nojsoncallback' => 1));
     $response = HTTP::post($this->flickrApiUrl, $params);
     if ($response !== false) {
         $response = json_decode($response, true);
     }
     if (isset($response['photo']['owner']['nsid'])) {
         $userIds[] = $response['photo']['owner']['nsid'];
     }
     // what Flickr calls 'username' can change at any time and so is worthless for blacklisting
     // path_alias is the username in the pretty URL; once set, it cannot be changed.
     if (isset($response['photo']['owner']['path_alias'])) {
         $userIds[] = $response['photo']['owner']['path_alias'];
     }
     return $userIds;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:26,代码来源:UploadWizardFlickrBlacklist.php

示例6: _execute

 protected function _execute($data)
 {
     $request = new HTTP($this->_apiURL);
     $response = $request->post($data);
     return $this->_parseResponse($response);
 }
开发者ID:stanleyalves,项目名称:icecast2-php-api,代码行数:6,代码来源:Gracenote.class.php

示例7: unset

require '../../model/Date.inc.php';
require '../../model/Utilities.inc.php';
class Z_Tests
{
    public static $AWS;
}
//
// Set up AWS service factory
//
$awsConfig = ['region' => $config['awsRegion']];
// IAM role authentication
if (empty($config['awsAccessKey'])) {
    $awsConfig['credentials.cache'] = new Guzzle\Cache\DoctrineCacheAdapter(new Doctrine\Common\Cache\FilesystemCache('work/cache'));
} else {
    $awsConfig['key'] = $config['awsAccessKey'];
    $awsConfig['secret'] = $config['awsSecretKey'];
}
Z_Tests::$AWS = \Aws\Common\Aws::factory($awsConfig);
unset($awsConfig);
// Wipe data and create API key
require_once 'http.inc.php';
$response = HTTP::post($config['apiURLPrefix'] . "test/setup?u=" . $config['userID'], " ", [], ["username" => $config['rootUsername'], "password" => $config['rootPassword']]);
$json = json_decode($response->getBody());
if (!$json) {
    echo $response->getBody();
    throw new Exception("Invalid test setup response");
}
$config['apiKey'] = $json->apiKey;
\Zotero\Tests\Config::update($config);
// Set up groups
require 'groups.inc.php';
开发者ID:juego11,项目名称:dataserver,代码行数:31,代码来源:bootstrap.inc.php

示例8: testPOSTFileKV

 public function testPOSTFileKV()
 {
     $res = HTTP::post('http://httpbin.org/post')->attach('asset', __DIR__ . '/files/cat.png')->send();
     $this->assertFalse($res->error());
     $this->assertEquals(200, $res->status());
     $this->assertEquals((object) array('asset' => 'data:image/jpeg;base64,' . base64_encode(file_get_contents(__DIR__ . '/files/cat.png'))), $res->body()->files);
 }
开发者ID:thomseddon,项目名称:http,代码行数:7,代码来源:HTTPTest.php

示例9: post

 public static function post($url, $data, $headers = array(), $auth = false)
 {
     self::loadConfig();
     $url = self::$config['apiURLPrefix'] . $url;
     $response = HTTP::post($url, $data, $headers, $auth);
     return $response;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:7,代码来源:api.inc.php

示例10: req

 private static function req($sessionID, $path, $params = array(), $gzip = false, $allowError = false)
 {
     $url = self::$config['syncURLPrefix'] . $path;
     $params = array_merge(array("sessionid" => $sessionID, "version" => self::$config['syncVersion']), $params ? $params : array());
     if ($gzip) {
         $data = "";
         foreach ($params as $key => $val) {
             $data .= $key . "=" . urlencode($val) . "&";
         }
         $data = gzdeflate(substr($data, 0, -1));
         $headers = ["Content-Type: application/octet-stream", "Content-Encoding: gzip"];
     } else {
         $data = $params;
         $headers = [];
     }
     if (!empty(self::$config['zoteroVersion'])) {
         $headers[] = "X-Zotero-Version: " . self::$config['zoteroVersion'];
     }
     $response = HTTP::post($url, $data, $headers);
     self::checkResponse($response, $allowError);
     return $response;
 }
开发者ID:selenus,项目名称:dataserver,代码行数:22,代码来源:sync.inc.php

示例11: req

 private function req($path, $params = array(), $gzip = false)
 {
     $url = self::$config['syncURLPrefix'] . $path;
     $params = array_merge(array("sessionid" => self::$sessionID, "version" => self::$config['apiVersion']), $params);
     if ($gzip) {
         $data = "";
         foreach ($params as $key => $val) {
             $data .= $key . "=" . urlencode($val) . "&";
         }
         $data = gzdeflate(substr($data, 0, -1));
         $headers = array("Content-Type: application/octet-stream", "Content-Encoding: gzip");
     } else {
         $data = $params;
         $headers = array();
     }
     $response = HTTP::post($url, $data, $headers);
     Sync::checkResponse($response);
     return $response;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:19,代码来源:SyncTest.php


注:本文中的HTTP::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。