samedi 28 janvier 2017

How to post data in another application using Guzzle?

I want to send data from one application to another .. where i want to send the first application data to second application form.. For that I used guzzle. And the platform I used Laravel.

Here is the first application controller :

public function store(Request $request)
    {
        $payment = new Payment();
        $payment->username = $request->Input(['username']);
        $payment->price = $request->Input(['price']);
        $payment->purchase_id = $request->Input(['purchase_id']);
        $payment->save();
        $store_id =\Hash::make($payment->id);
        $price = $payment->price; 
        $client = new Client();
        $response = $client->request('GET', 'http://localhost/b/public/api/getPayment',[
            'form_params'=>[
                'store_id'=>$store_id
            ]
            ]);
    }

And the second application form :

 {!! Form::open(['method' => 'POST', 'route' => 'store', 'class'=>'form-horizontal','enctype'=>'multipart/form-data']) !!}
           {!! csrf_field() ; !!}                
                    <div class="form-group">
                        <label>Store ID</label>
                        <input type="text" class="form-control" name="storeId" value=""  placeholder="Store ID">
                    </div>
                    <button type="submit" class="btn btn-default">Submit</button>
            {!! Form::close() !!}

And in second Controller I put the route in api.php

Route::get('/getPayment',[
    'uses'=>'PaymentController@create',
    'as'=>'create'
    ]);

But i got the following Error:

ServerException in RequestException.php line 111:
Server error: `GET http://localhost/b/public/api/getPayment` resulted in a `500

Internal Server Error` response:



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kfN23q
via IFTTT

Aucun commentaire:

Enregistrer un commentaire