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


PHP Client::post方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $email = $request->email;
     $password = $request->password;
     $client = new Client();
     $res = $client->post('https://api.pragyan.org/user/eventauth', array('body' => array('user_email' => $email, 'event_id' => '39', 'user_pass' => $password)));
     $res = json_decode($res->getBody(), true);
     if ($res['status'] > 0) {
         if (User::where('email', $email)->exists()) {
             $user = User::where('email', $email)->first();
             Session::put('user_id', $user->PID);
             return redirect('home');
         }
         $res = $client->post('https://api.pragyan.org/user/getDetails', array('body' => array('user_email' => $email, 'user_pass' => $password)));
         $res = json_decode($res->getBody(), true);
         if ($res['status'] == 2) {
             $user = new User();
             $user->name = $res['data']['user_fullname'];
             $user->prag_pid = $res['data']['user_id'];
             $user->email = $email;
             $user->save();
             $user = User::where('email', $email)->first();
             Session::put('user_id', $user->PID);
             return redirect('home');
         } else {
             return view('login', ['error' => 'Try after sometime']);
         }
     } else {
         return view('login', ['error' => 'Email or password incorrect! If not registered, register at <a href="http://prgy.in/mdecoder">prgy.in/mdecoder</a>']);
     }
 }
开发者ID:Aditya-Balaji,项目名称:MDecoder,代码行数:37,代码来源:LoginController.php

示例2: registerWebPayModule

 public function registerWebPayModule($payment = 'capture')
 {
     $I = $this;
     $I->login();
     $I->amOnPage('/admin/load_module_config.php?module_id=' . MDL_WEBPAY_ID);
     $I->fillField('secret_key', WEBPAY_SECRET_KEY);
     $I->fillField('publishable_key', WEBPAY_PUBLISHABLE_KEY);
     $I->selectOption('input[name=payment]', $payment);
     $I->click('この内容で登録する');
     $I->amOnPage('/admin/ownersstore/');
     $uri = 'http://localhost:9999/admin/ownersstore/';
     $transactionId = $I->grabAttributeFrom('input[name=transactionid]', 'value');
     $sessionId = $I->grabCookie('ECSESSID');
     // posting file and handling confirm window are impossible for ghostdriver
     $client = new Client();
     $I->expectTo('install plugin');
     $client->post($uri, ['body' => ['transactionid' => $transactionId, 'mode' => 'install', 'plugin_file' => fopen('WebPayExt.tar.gz', 'r')], 'cookies' => ['ECSESSID' => $sessionId]]);
     $client->post($uri, ['body' => ['transactionid' => $transactionId, 'mode' => 'enable', 'plugin_id' => 1, 'enable' => 1], 'cookies' => ['ECSESSID' => $sessionId]]);
     $I->amOnPage('/admin/ownersstore/');
     $I->see('WebPay決済モジュール拡張プラグイン');
     $I->seeCheckboxIsChecked('input#plugin_enable');
     $I->seeInDatabase('dtb_payment', array('payment_id' => 5, 'memo03' => MDL_WEBPAY_CODE));
     $I->haveInDatabase('dtb_payment_options', array('deliv_id' => 1, 'payment_id' => 5, 'rank' => 5));
     $I->haveInDatabase('dtb_payment_options', array('deliv_id' => 2, 'payment_id' => 5, 'rank' => 2));
 }
开发者ID:ttsuru,项目名称:mdl_webpay,代码行数:25,代码来源:AdminSteps.php

示例3: send

 /**
  * Send http request to api and return response.
  *
  * @param string $operation the operation type to perform
  * @param array $args
  *
  * @return Response
  */
 public function send($operation_type, array $args)
 {
     $fields = array_merge($this->authParams(), $args, compact('operation_type'));
     $response = new Response($this->client->post($this->apiUrl, ['body' => Xml::arrayToXml($fields)]));
     $response->offsetSet('original_args', $args);
     return $response;
 }
开发者ID:RDelorier,项目名称:first-americam-xml,代码行数:15,代码来源:Gateway.php

示例4: makeHttpRequest

 /**
  * Make a Http Request
  * @param       string          $method         The Http verb
  * @param       string          $url            The relative URL after the host name
  * @param       array|null      $apiRequest     Contents of the body
  * @param       array|null      $queryString    Data to add as a queryString to the url
  * @return      mixed
  * @throws      RequiredFieldMissingException
  * @throws      ConnectException
  * @throws      RequestException
  * @throws      \Exception
  */
 public function makeHttpRequest($method, $url, $apiRequest = null, $queryString = null)
 {
     $this->apiConfiguration->validate();
     $urlEndPoint = $this->apiConfiguration->getApiEndPoint() . '/' . $url;
     $data = ['headers' => ['Authorization' => 'Bearer ' . $this->apiConfiguration->getAccessToken()], 'json' => $apiRequest, 'query' => $queryString];
     try {
         switch ($method) {
             case 'post':
                 $response = $this->guzzle->post($urlEndPoint, $data);
                 break;
             case 'put':
                 $response = $this->guzzle->put($urlEndPoint, $data);
                 break;
             case 'delete':
                 $response = $this->guzzle->delete($urlEndPoint, $data);
                 break;
             case 'get':
                 $response = $this->guzzle->get($urlEndPoint, $data);
                 break;
             default:
                 throw new \Exception('Missing request method');
         }
         if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg'])) {
             $result = $response->getBody()->getContents();
         } else {
             $result = json_decode($response->getBody(), true);
         }
         return $result;
     } catch (ConnectException $c) {
         throw $c;
     } catch (RequestException $e) {
         throw $e;
     }
 }
开发者ID:caravanarentals,项目名称:base-php-wrapper,代码行数:46,代码来源:HttpRequest.php

示例5: retrieveByCredentials

 /**
  * Retrieve a user by the given credentials.
  *
  * @param array $credentials
  *
  * @return \Magister\Services\Database\Elegant\Model|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     $body = ['body' => $credentials];
     $this->client->delete('sessies/huidige');
     $this->client->post('sessies', $body);
     return $this->retrieveByToken();
 }
开发者ID:JeroenJochems,项目名称:Magister,代码行数:14,代码来源:ElegantUserProvider.php

示例6: createTeamMembership

 public function createTeamMembership($teamId = '', $options = array())
 {
     if (sizeOf($options) < 1 || $teamId == '') {
         return ApiException::errorMessage(999);
     }
     $requestParams = array();
     $requestParams["teamId"] = $teamId;
     if (isset($options["personId"])) {
         $requestParams["personId"] = $options["personId"];
     }
     if (isset($options["personEmail"])) {
         $requestParams["personEmail"] = $options["personEmail"];
     }
     if (isset($options["isModerator"])) {
         $requestParams["isModerator"] = $options["isModerator"];
     }
     $mJson = json_encode($requestParams);
     $client = new Client();
     try {
         $response = $client->post(self::TEAMMEMBERSHIPURI, array('headers' => $this->getBaseHeaders(), 'body' => $mJson, 'verify' => false));
     } catch (ClientException $e) {
         $errorResponse = $e->getResponse();
         $statusCode = $errorResponse->getStatusCode();
         if ($statusCode == 401) {
             $response = $client->post(self::TEAMMEMBERSHIPURI, array('headers' => $this->getRefreshHeaders(), 'body' => $mJson, 'verify' => false));
         } else {
             if ($statusCode != 200) {
                 return ApiException::errorMessage($statusCode);
             }
         }
     }
     return $response;
 }
开发者ID:CiscoVE,项目名称:SparkBundle,代码行数:33,代码来源:TeamMembership.php

示例7: postMo

 public function postMo(array $messageArr)
 {
     try {
         $this->msgCounter++;
         $words = explode(' ', $messageArr['text']);
         $moParams = array_merge($this->config['mo'], $messageArr, array('message_id' => $this->msgCounter, 'keyword' => $words[0] . '@' . $messageArr['short_id']));
         echo "Posting params from MO to client @" . $messageArr['url'] . ': ' . json_encode($moParams) . "\n";
         $response = $this->httpClient->post($messageArr['url'], ['body' => $moParams]);
         if ($response->getStatusCode() != 200) {
             echo 'received MO reply with status code: ' . $response->getStatusCode() . ', and body' . $response->getBody() . "\n";
             return $this->sendError($response->getBody());
         }
         $responseBody = $response->getBody();
         echo 'received MO reply:' . $responseBody . "\n";
         $this->broadcast('mo_reply', array('message' => $this->parseXMLResponse($responseBody)));
     } catch (\GuzzleHttp\Exception\RequestException $requestException) {
         echo 'received MO reply error of class [' . get_class($requestException) . '] and message: ' . $requestException->getMessage() . "\n";
         if ($requestException->hasResponse()) {
             echo "\nbody: " . $requestException->getResponse()->getBody() . "\n";
             echo "\ncode: " . $requestException->getResponse()->getStatusCode() . "\n";
             $this->sendError($requestException->getMessage(), $this->parseXMLResponse($requestException->getResponse()->getBody()));
         }
         $this->sendError($requestException->getMessage());
     } catch (\Exception $exc) {
         echo 'received MO reply error of class [' . get_class($exc) . '] and message: ' . $exc->getMessage() . "\n";
         $this->sendError($exc->getMessage());
     }
 }
开发者ID:rukavina,项目名称:sms-inbound-mock,代码行数:28,代码来源:PremiumMockApp.php

示例8: request

 /**
  * Makes a request to a URL.
  *
  * @param string $request
  * @param array  $params
  *
  * @return \Psr7\Request
  */
 protected function request($request, array $params = [])
 {
     $endpoint = $this->config->get('centurian.endpoint');
     $uri = sprintf('%s/%s', $endpoint, $request);
     $data = ['form_params' => $params, 'auth' => [$this->config->get('centurian.token'), null]];
     return $this->client->post($uri, $data);
 }
开发者ID:bran921007,项目名称:Centurian,代码行数:15,代码来源:Centurian.php

示例9: execute

 /**
  * Execute the command.
  *
  * @param InputInterface $input The input.
  * @param OutputInterface $output The output.
  * @throws InvalidArgumentException If the configuration is not specified.
  * @return integer
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configFile = $input->getOption('config-file');
     $config = Yaml::parse(file_get_contents($configFile), true);
     if (!isset($config['strava']['auth'])) {
         throw new InvalidArgumentException('There is no configuration specified for tracker "strava". See example config.');
     }
     $secretToken = $config['strava']['auth']['secretToken'];
     $clientID = $config['strava']['auth']['clientID'];
     $username = $config['strava']['auth']['username'];
     $password = $config['strava']['auth']['password'];
     $httpClient = new Client();
     /** @var \GuzzleHttp\Message\ResponseInterface $response */
     // Do normal login.
     $response = $httpClient->get('https://www.strava.com/login', ['cookies' => true]);
     $authenticityToken = $this->getAuthenticityToken($response);
     // Perform the login to strava.com
     $httpClient->post('https://www.strava.com/session', array('cookies' => true, 'body' => array('authenticity_token' => $authenticityToken, 'email' => $username, 'password' => $password)));
     // Get the authorize page.
     $response = $httpClient->get('https://www.strava.com/oauth/authorize?client_id=' . $clientID . '&response_type=code&redirect_uri=http://localhost&scope=view_private,write&approval_prompt=force', ['cookies' => true]);
     $authenticityToken = $this->getAuthenticityToken($response);
     // Accept the application.
     $response = $httpClient->post('https://www.strava.com/oauth/accept_application?client_id=' . $clientID . '&response_type=code&redirect_uri=http://localhost&scope=view_private,write', array('cookies' => true, 'allow_redirects' => false, 'body' => array('authenticity_token' => $authenticityToken)));
     $redirectLocation = $response->getHeader('Location');
     $urlQuery = parse_url($redirectLocation, PHP_URL_QUERY);
     parse_str($urlQuery, $urlQuery);
     $authorizationCode = $urlQuery['code'];
     // Token exchange.
     $response = $httpClient->post('https://www.strava.com/oauth/token', array('body' => array('client_id' => $clientID, 'client_secret' => $secretToken, 'code' => $authorizationCode)));
     $jsonResponse = $response->json();
     $code = $jsonResponse['access_token'];
     $output->writeln('Your access token is: <comment>' . $code . '</comment>');
     return 0;
 }
开发者ID:JavierMartinz,项目名称:SportTrackerConnector,代码行数:42,代码来源:GetToken.php

示例10: post

 public function post($resource, $body, $type, $options = [])
 {
     $options['body'] = $this->serializer->serialize($body, 'json');
     $options['headers'] = ['Content-Type' => 'application/json'];
     $content = $this->client->post($resource, $options)->getBody()->getContents();
     return $this->deserialize($content, $type);
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:7,代码来源:GuzzleAdapter.php

示例11: post

 public function post($full_url, array $multi_parts = [], array $headers = [])
 {
     $options = ['debug' => GUZZLE_DEBUG];
     // Grab the client's handler instance.
     $clientHandler = $this->client->getConfig('handler');
     // Create a middleware that echoes parts of the request.
     $tapMiddleware = Middleware::tap(function ($request) {
         echo $request->getHeader('Content-Type');
         // application/json
         echo $request->getBody();
         // {"foo":"bar"}
     });
     //$options['handler'] = $tapMiddleware($clientHandler);
     $multi_part_vars = array();
     foreach ($multi_parts as $name => $data) {
         if (is_array($data)) {
             $data['name'] = $name;
         } else {
             $data = ['name' => $name, 'contents' => $data];
         }
         $multi_part_vars[] = $data;
     }
     $options['multipart'] = $multi_part_vars;
     //$options['headers'] = ['Referer' =>  $full_url];
     if (!empty($headers)) {
         $options['headers'] = $headers;
     }
     $this->response = $this->client->post($full_url, $options);
     return $this;
 }
开发者ID:vantt,项目名称:vocabulary-crawler,代码行数:30,代码来源:GuzzleHttpRequest.php

示例12: validate

 /**
  * {@inheritdoc}
  */
 public function validate($uri, $secret, $response, $remoteIp = NULL)
 {
     $params = ['secret' => $secret, 'response' => $response];
     if ($remoteIp !== NULL) {
         $params['remoteip'] = $remoteIp;
     }
     return $this->client->post($uri, ['query' => $params]);
 }
开发者ID:lookyman,项目名称:recaptcha,代码行数:11,代码来源:GuzzleClient.php

示例13: send

 /**
  * Send the given notification.
  *
  * @param  mixed  $notifiable
  * @param  \Illuminate\Notifications\Notification  $notification
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function send($notifiable, Notification $notification)
 {
     if (!($url = $notifiable->routeNotificationFor('slack'))) {
         return;
     }
     $message = $notification->toSlack($notifiable);
     return $this->http->post($url, ['json' => ['text' => $message->content, 'attachments' => $this->attachments($message)]]);
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:15,代码来源:SlackWebhookChannel.php

示例14: testGetAccessToken

 public function testGetAccessToken()
 {
     $response = self::$client->post('/');
     $token = $response->json();
     $this->assertEquals("v6574b42-a5bc-4574-a87f-5c9d1202e316", $token['access_token']);
     $this->assertEquals("308874923", $token['expires_in']);
     $this->assertEquals("Bearer", $token['token_type']);
 }
开发者ID:GafaMX,项目名称:dev_funciones_basicas,代码行数:8,代码来源:CtctOAuth2UnitTest.php

示例15: publish

 /**
  * {@inheritdoc}
  */
 public function publish(Event $event)
 {
     try {
         $this->client->post(self::PUBLISH_URL, ['body' => $this->serializer->serialize($event, 'json')]);
     } catch (BadResponseException $exception) {
         throw new PublishException($exception->getMessage());
     }
 }
开发者ID:nicolasdewez,项目名称:events-bundle,代码行数:11,代码来源:HttpConnector.php


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