本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface::setPostField方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::setPostField方法的具体用法?PHP RequestInterface::setPostField怎么用?PHP RequestInterface::setPostField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::setPostField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addParameter
/**
* Add a parameter key and value to the request according to type
*
* @param RequestInterface $request The request
* @param string $key The name of the parameter
* @param string $value The value of the parameter
*/
public function addParameter(RequestInterface $request, $key, $value)
{
if ($request->getMethod() == 'POST') {
$request->setPostField($key, $value);
} else {
$request->getQuery()->set($key, $value);
}
}
示例2: __construct
public function __construct(ConnectionInterface $conn, RequestInterface $req)
{
$body = (string) $req->getBody();
if (!empty($body)) {
$query = QueryString::fromString($body);
$fields = $query->getAll();
foreach ($fields as $field => $value) {
$req->setPostField($field, $value);
}
}
$this->conn = $conn;
$this->session = $conn->Session;
$this->req = $req;
}
示例3: visit
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
$request->setPostField($param->getWireName(), $this->prepareValue($value, $param));
}
示例4: sendTradeAPIRequest
/**
* @param RequestInterface $request
* @param int $retryNo
*
* @return mixed
* @throws RemoteError
*/
protected function sendTradeAPIRequest(RequestInterface $request, $retryNo = 0)
{
if ($request instanceof EntityEnclosingRequest) {
$nonce = (int) bcmul(bcadd(time(), substr(microtime(), 0, 3), 1), 10) - 13000000000.0;
$request->setPostField('nonce', $nonce);
$request->setHeader('Sign', hash_hmac('sha512', $request->getPostFields(), $this->apiSecret));
$request->setHeader('Key', $this->apiKey);
}
$response = $this->send($request);
$data = $request->getResponse()->json();
if ($response->isSuccessful() && isset($data['success']) && 1 === $data['success']) {
return $data['return'];
} elseif ($response->isServerError() && $retryNo <= self::RETRY_COUNT) {
sleep(self::RETRY_INTERVAL);
return $this->sendTradeAPIRequest($request, ++$retryNo);
} else {
throw new RemoteError(isset($data['error']) ? $data['error'] : null);
}
}
示例5: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, RequestInterface $request, $key, $value)
{
$request->setPostField($key, $value);
}