Reputation: 297
I am trying to post data from one sperate laravel website to another laravel site.
I am sending register post request from abc.com controller to xyz.com register controller.
abc.com structure
web.php
Route::post('register','SiteController@register')->name('register');
SiteController.php
public function register(Request $request){
$full_name = $request->input('full_name');
$email_address = $request->input('email_address');
$password = $request->input('password');
$data = [];
$data['full_name'] = $full_name;
$data['email'] = $email_address;
$data['password'] = $password;
}
xyz.com site structure
using https://github.com/jeremykenedy/laravel-auth for login and registration.
I tried various options from requests, redirect, curl and also tried guzzle
But no luck.
Thank you.
Upvotes: 1
Views: 7913
Reputation: 333
You want Http::post
use Illuminate\Support\Facades\Http;
$response = Http::post('http://example.com/users', [
'name' => 'Steve',
'role' => 'Network Administrator',
]);
https://laravel.com/docs/8.x/http-client#request-data
Upvotes: 2
Reputation: 101
CURL should be enough to post data to different url (in this case xyz.com). Make sure the csrf is disabled since it's a POST request from different laravel app In Laravel 5, How to disable VerifycsrfToken middleware for specific route? if this still fail, check the log on laravel app
Upvotes: 2
Reputation: 315
You can use curl
But i think you are trying to complicate it a bit, just change action in form to external url
Upvotes: 0