1

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.

anaszaman
  • 297
  • 6
  • 19
  • Possible duplicate of [How to handle incoming POST data from external server in Laravel](https://stackoverflow.com/questions/46045179/how-to-handle-incoming-post-data-from-external-server-in-laravel) – Andrew Aug 20 '18 at 20:54

3 Answers3

2

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

Gerry
  • 101
  • 1
  • 7
2

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

Oriol Vilaseca
  • 317
  • 3
  • 7
0

You can use curl

POST data to a URL in PHP

But i think you are trying to complicate it a bit, just change action in form to external url

colorgreen
  • 265
  • 1
  • 2
  • 12