本文整理汇总了PHP中Client::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::post方法的具体用法?PHP Client::post怎么用?PHP Client::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignToUser
public function assignToUser($pid, $uid, $filters = [])
{
$result = $this->client->post("/gdc/md/{$pid}/userfilters", ['userFilters' => ['items' => [["user" => Users::getUriFromUid($uid), "userFilters" => $filters]]]]);
if (!isset($result['userFiltersUpdateResult']['successful']) || !count($result['userFiltersUpdateResult']['successful'])) {
throw Exception::unexpectedResponseError('Assign filters to user failed', 'POST', "/gdc/md/{$pid}/userfilters", $result);
}
}
示例2: getToken
private function getToken()
{
if (!$this->token) {
$response = $this->client->post('tokens', '', json_encode(array("username" => $this->username, "password" => $this->password)))->send();
$this->token = $response->json();
}
return $this->token;
}
示例3: createUser
public function createUser($login, $password, $domain, array $options = [])
{
$result = $this->client->post("/gdc/account/domains/{$domain}/users", ['accountSetting' => array_merge(['login' => strtolower($login), 'email' => strtolower($login), 'password' => $password, 'verifyPassword' => $password], $options)]);
if (isset($result['uri'])) {
return self::getUidFromUri($result['uri']);
} else {
throw Exception::unexpectedResponseError('Create user failed', 'POST', "/gdc/account/domains/{$domain}/users", $result);
}
}
示例4: schedule
public function schedule($to, $txt, $date)
{
$client = new Client($this->user, $this->token);
$data = array("destinations" => $to, "text" => $txt, "scheduleDate" => $date);
$response = $client->post('messages', $data);
return $response->scheduleId;
}
示例5: send
public function send($to, $txt)
{
$client = new Client($this->user, $this->token);
$data = array("destinations" => $to, "text" => $txt);
$response = $client->post('messages', $data);
return $response->deliveryToken;
}
示例6: testPost
public function testPost()
{
$client = new Client('', '', false);
$email = array('FromName' => 'Mailjet PHP test', 'FromEmail' => 'dev@amo-soft.com', 'Text-Part' => 'Simple Email test', 'Subject' => 'PHPunit', 'Html-Part' => '<h3>Simple Email Test</h3>', 'Recipients' => array(array('Email' => 'test@mailjet.com')), 'MJ-custom-ID' => 'Hello ID');
$ret = $client->post(Resources::$Email, array('body' => $email));
$this->assertUrl('/send', $ret);
$this->assertPayload($email, $ret);
}
示例7: testPost
public function testPost()
{
$client = new Client('', '', false);
$email = ['FromName' => 'Mailjet PHP test', 'FromEmail' => 'gbadi@student.42.fr', 'Text-Part' => 'Simple Email test', 'Subject' => 'PHPunit', 'Html-Part' => '<h3>Simple Email Test</h3>', 'Recipients' => [['Email' => 'test@mailjet.com']], 'MJ-custom-ID' => 'Hello ID'];
$ret = $client->post(Resources::$Email, ['body' => $email]);
$this->assertUrl('/send', $ret);
$this->assertPayload($email, $ret);
}
示例8: postSignedJSON
/**
* Perform a POST request, get a decoded JSON response.
* Internally verifies an Ed25519 signature.
*
* @param string $url
* @param SignaturePublicKey $publicKey
* @param array $params
* @return mixed
*/
public function postSignedJSON(string $url, SignaturePublicKey $publicKey, array $params = [])
{
$response = $this->client->post($url, $this->params($params, $url));
if ($response instanceof Response) {
return $this->parseSignedJSON($response, $publicKey);
}
return null;
}
示例9: create
public function create($options = [])
{
$data = Client::post(static::endpoint(), $this->payload(), $options);
if (count($data) > 0) {
$data = json_decode($data, true);
}
return $this->parse($data);
}
示例10: getRefreshToken
public static function getRefreshToken($code)
{
$endpoint = 'https://connect.stripe.com/oauth/token';
$params = array('client_secret' => $_ENV['STRIPE_SECRET_KEY'], 'code' => $code, 'grant_type' => 'authorization_code');
$url = self::makeurl($endpoint, $params);
$client = new Client();
$returned_object = $client->post($endpoint, ['body' => $params])->json();
return $returned_object;
}
示例11: diff
public function diff($pid, $model)
{
$uri = "/gdc/projects/{$pid}/model/diff?includeDeprecated=true&includeGrain=true";
$result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
if (isset($result['asyncTask']['link']['poll'])) {
$try = 1;
do {
sleep(10 * $try);
$taskResponse = $this->client->get($result['asyncTask']['link']['poll']);
if (!isset($taskResponse['asyncTask']['link']['poll'])) {
if (isset($taskResponse['projectModelDiff']['updateScripts'])) {
$lessDestructive = [];
$moreDestructive = [];
// Preserve data if possible
foreach ($taskResponse['projectModelDiff']['updateScripts'] as $updateScript) {
if ($updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($lessDestructive) && !$updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!$updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($moreDestructive) && $updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
}
$description = [];
foreach ($taskResponse['projectModelDiff']['updateOperations'] as $o) {
$description[] = vsprintf($o['updateOperation']['description'], $o['updateOperation']['parameters']);
}
return ['moreDestructiveMaql' => $moreDestructive, 'lessDestructiveMaql' => $lessDestructive, 'description' => $description];
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be finished', 'GET', $result['asyncTask']['link']['poll'], $taskResponse);
}
}
$try++;
} while (true);
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be started', 'POST', $uri, $result);
}
return false;
}
示例12: disableUser
public function disableUser($uid, $pid)
{
try {
$result = $this->client->get("/gdc/projects/{$pid}/users/{$uid}");
$this->client->post("/gdc/projects/{$pid}/users", ['user' => ['content' => ['status' => 'DISABLED', 'userRoles' => $result['user']['content']['userRoles']], 'links' => ['self' => $result['user']['links']['self']]]]);
} catch (Exception $e) {
if ($e->getCode() != 404) {
throw $e;
}
}
}
示例13: testPOST
public function testPOST()
{
// create our http client (Guzzle)
$client = new Client('http://localhost:8000', array('request.options' => array('exceptions' => false)));
$nickname = 'ObjectOrienter' . rand(0, 999);
$data = array('nickname' => $nickname, 'avatarNumber' => 5, 'tagLine' => 'a test dev!');
$request = $client->post('/api/programmers', null, json_encode($data));
$response = $request->send();
$this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->hasHeader('Location'));
$data = json_decode($response->getBody(true), true);
$this->assertArrayHasKey('nickname', $data);
}
示例14: loadData
public function loadData($pid, $dirName)
{
$uri = "/gdc/md/{$pid}/etl/pull2";
$result = $this->client->post($uri, ['pullIntegration' => $dirName]);
if (isset($result['pull2Task']['links']['poll'])) {
$try = 1;
do {
sleep(10 * $try);
$taskResponse = $this->client->get($result['pull2Task']['links']['poll']);
if (!isset($taskResponse['wTaskStatus']['status'])) {
throw Exception::unexpectedResponseError('ETL task could not be checked', 'GET', $result['pull2Task']['links']['poll'], $taskResponse);
}
$try++;
} while ($taskResponse['wTaskStatus']['status'] == 'RUNNING');
if ($taskResponse['wTaskStatus']['status'] == 'ERROR') {
$errors = [];
if (isset($taskResponse['messages'])) {
foreach ($taskResponse['messages'] as $m) {
if (isset($m['error'])) {
$errors[] = Exception::parseMessage($m['error']);
}
}
}
if (isset($taskResponse['wTaskStatus']['messages'])) {
foreach ($taskResponse['wTaskStatus']['messages'] as $m) {
if (isset($m['error'])) {
$errors[] = Exception::parseMessage($m['error']);
}
}
}
throw new Exception($errors);
}
return isset($taskResponse['messages']) ? $taskResponse['messages'] : [];
} else {
throw Exception::unexpectedResponseError('ETL task failed', 'POST', $uri, $result);
}
}
示例15: send
/**
* Send notification to LeanCloud
*
* @return array
*/
public function send()
{
$out = $this->encode();
$resp = Client::post("/push", $out);
return $resp;
}