Category : guzzle

How to pass pdf file through http client in php laravel 8? I need to get a pdf file from the user and upload it to a 3rd party service. I am doing the below: $file = $request->file(‘pdf’); $response = Http::withOptions([ ‘ssl_key’ => $pemPath, ‘cert’ => $crtPath ])->accept(‘application/json’) ->contentType(‘application/json’) ->attach(‘file’,file_get_contents($file)) ->post(‘https://domainname.com/api/client/session/’); It keeps give me ..

Read more

How to pass client certificate (2 files .key and .pem) through http client request? I need to include those files in the below http post request to be able to talk with the server. $response = Http::post(‘https://domainname.com/api/client/session’, array(‘xxx’ => array(‘xx’ => ‘xxxx’))); I am able to do it using phpCurl like below: $curl = curl_init(); ..

Read more

I am trying to post an object using Guzzle laravel which I pass it using form submit from my view but when I do it says INVALID FORMAT Json Cannot be Parsed My View <form method="POST" action="comparePrices"> @csrf <input type="text" name="datas" id="textsss"/> <input type="submit" value="save"/> </form> But when I post it via postman it works ..

Read more

public static function send() { $products = Product::where(‘active’, 1)->get([‘id_product’, ‘price’, ‘reference’])->load([‘images’, ‘lang’]); // loop for all products and sending to API $number_of_products = count($products); $start = 0; $end = 70; for ($a = 0; $a < ceil($number_of_products/70); $a++) { for ($i = $start; $i < $end; $i++) { // loop for all images in product ..

Read more

I am using Guzzle for retrieving data from Amadeus. It works fine with Postman and also if I call with Ajax it works fine but when I want to retrieve data from the controller it says bad request. Postman public function agentsTicket(Request $request) { $client = new Client(); try { $res = $client->Get(‘https://test.api.amadeus.com/v2/shopping/flight-offers’, [ ‘headers’ ..

Read more

I am building a PHP telegram bot platform, and I have been struggling with getting MediaGroup messages to work. I have managed to get a single Photo to upload using Guzzle using the code below. function sendPhoto($chat_id, $photo, $filename, $caption, $parse_mode = "markdown", $disable_notification = false, $reply_to_message_id = 0, $allow_sending_without_reply = false, $reply_markup = null){ ..

Read more

I get the error I’ve written in the title. Here are my codes. public function testItCanCreateDataWithAPI() { $data = [ ‘json’ => [ ‘name’ => ‘API’, ‘user’ => ‘Pouya’, ’email’ => ‘[email protected]’, ‘link’ => ‘api.com’ ] ]; $response = $this->httpClient->post(‘index.php’, $data); echo $response->getBody(); } } my httpClient class: class HttpClient extends Client { public function ..

Read more