本文整理匯總了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);
}