guzzle

Upload multiple files from Client to Server via API using HTTP guzzle in laravel 8

寵の児 提交于 2021-01-29 21:53:45
问题 I tested by postman to attach file with field fileupload[0](see screenshot below) that works fine, request is added and fileupload also uploaded to server. But I want to call that upload file api by my laravel HTTP Client I have tried below code $result = Http::attach( 'attachment', $request->fileupload )->asForm()->post('http://192.168.1.100/api/request/store', $form_param); my control in form upload: <input type="file" name="fileupload[]" multiple> But it seem like API server does not get

GuzzleHttp Error: Call to undefined method GuzzleHttp\Client::sendAsync()

荒凉一梦 提交于 2021-01-29 20:43:04
问题 I am using GuzzleHttp 6.5.5 Setting up payment gateway AuthorizeNet. Composer.json file is "require": { "league/omnipay": "^3.0", "academe/omnipay-authorizenetapi": " ~3.0", "php-http/guzzle6-adapter": "1.1.1" } Payment Code: require_once('assets/import/authorizenet/vendor/autoload.php'); $gateway = Omnipay\Omnipay::create('AuthorizeNetApi_Api'); $gateway->setAuthName($pt->config->anet_login_id); $gateway->setTransactionKey($pt->config->anet_transaction_id); $gateway->setTestMode(true);

How do you send data to the server onload using ratchet websockets?

☆樱花仙子☆ 提交于 2021-01-29 12:07:02
问题 I have session variables stored on the client. (in this example, session var is "username" with value "Foo") I need the server to know that the new connection that just loaded in has the name "Foo." is there any way to have the server know the value of a session variable? 回答1: No, you cannot do that. Sessions are stored in the cookies and Ratchet cannot access them. However, I use this approach when I am working with web-sockets: Create a hash when the user logins into the account and store

POST request to Clevertap using GuzzleHttp

回眸只為那壹抹淺笑 提交于 2021-01-28 11:26:57
问题 I am using Laravel 5.1 and Guzzlehttp 6.1 to make post request to clevertap. $client = new \GuzzleHttp\Client(['headers' => ['X-CleverTap-Account-Id' => '**********','X-CleverTap-Passcode'=>'*************8']]); $result = $client->request('POST','https://api.clevertap.com/1/upload',["d"=>[ "identity"=>"1189549", "ts"=>1419421212, "type"=>"profile", "profileData"=>[ "Name"=>"Jack Montana", "Email"=>"jack@gmail.com", "Phone"=>"+14155551234", "Gender"=>"M", "Employed"=>"Y", "Education"=>"Graduate

Laravel Passport - Feature test returns unauthorized 401

倾然丶 夕夏残阳落幕 提交于 2021-01-28 03:06:00
问题 I'm trying to test my login endpoint where a successful response would return the access_token among other things. I'm using RefreshDatabase , so I changed the login method on the controller to retrieve the client_secret via a DB call. I tested with a dd() and I can confirm that the client_secret changes on each phpunit run in the terminal. The credentials are correct and the API endpoint works - just not when it's run via a test. For example, I have the passport tables set up on my mysql

Microsoft graph Unable to read JSON request payload

僤鯓⒐⒋嵵緔 提交于 2021-01-28 01:53:00
问题 I'm trying to create subscriptions with microsoft graph in php, however I am unable to see what is going wrong at this point. The code is breaking at the following: protected $http_subscribe = "https://graph.microsoft.com/v1.0/subscriptions"; public function getSubscriptions() { if(empty($this->token)) { dd('no token supplied'); //some debugging } $date = $this->endTimeDate->format('Y-m-d'); //This is Carbon date $time = $this->endTimeDate->format('H:i:s.u'); $response = $this->client-

How to reset a Guzzle client and clear any cached values (memory usage)

妖精的绣舞 提交于 2021-01-27 11:31:28
问题 I have code similar to what's below (it's example code). Using Guzzle, I make multiple calls to the same site to see if a document exists. If the document exists, I save it. As I make each call, the memory usage goes up. Eventually, if the number of requests is high enough, I run out of memory. I used memory_get_peak_usage to track where the memory use was happening, and it's the Guzzle client. The code works as expected, but I cannot find a way to tell the Guzzle Client to "reset and dump

How to reset a Guzzle client and clear any cached values (memory usage)

↘锁芯ラ 提交于 2021-01-27 11:31:12
问题 I have code similar to what's below (it's example code). Using Guzzle, I make multiple calls to the same site to see if a document exists. If the document exists, I save it. As I make each call, the memory usage goes up. Eventually, if the number of requests is high enough, I run out of memory. I used memory_get_peak_usage to track where the memory use was happening, and it's the Guzzle client. The code works as expected, but I cannot find a way to tell the Guzzle Client to "reset and dump

Handling exceptions on a Pool of Requests

和自甴很熟 提交于 2021-01-27 07:05:59
问题 I'm using Guzzle to send a number of requests to an API endpoint, using the Pool functionality to send these asynchronously and concurrently. The script looks like this: use GuzzleHttp\Client; use GuzzleHttp\Promise; use GuzzleHttp\Pool; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Exception\RequestException; /* Configure logger */ Logger::configure("config/logger.xml"); $logger = Logger::getLogger("console"); /* Configure Guzzle Client */ $client = new Client([ 'base_uri' => 'http://my.api/',

Handling exceptions on a Pool of Requests

旧街凉风 提交于 2021-01-27 07:03:19
问题 I'm using Guzzle to send a number of requests to an API endpoint, using the Pool functionality to send these asynchronously and concurrently. The script looks like this: use GuzzleHttp\Client; use GuzzleHttp\Promise; use GuzzleHttp\Pool; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Exception\RequestException; /* Configure logger */ Logger::configure("config/logger.xml"); $logger = Logger::getLogger("console"); /* Configure Guzzle Client */ $client = new Client([ 'base_uri' => 'http://my.api/',