Laravel How do I request a third-party RESTful API interface?

Source: Internet
Author: User
With such a powerful framework, the development documentation doesn't tell you how to access third-party APIs with HTTP requests.
At present, Baidu comes out of several programs:

1. This program will be reported notfoundhttpexception, roughly debugging, as if the input route is not legal, there is no document to say how these 2 methods are used.

$req = Request::create('http://localhost:1920/api/User/GetUser','GET');$resp = Route::dispatch($req);

2. Using the curl frame, this should be possible, is not very want to use, want to use laravel built-in.
3. Using the guzzle framework, someone said that Laravel built the framework, but couldn't find it.

Reply content:

With such a powerful framework, the development documentation doesn't tell you how to access third-party APIs with HTTP requests.
At present, Baidu comes out of several programs:

1. This program will be reported notfoundhttpexception, roughly debugging, as if the input route is not legal, there is no document to say how these 2 methods are used.

$req = Request::create('http://localhost:1920/api/User/GetUser','GET');$resp = Route::dispatch($req);

2. Using the curl frame, this should be possible, is not very want to use, want to use laravel built-in.
3. Using the guzzle framework, someone said that Laravel built the framework, but couldn't find it.

Curl is already strong, laravel there's no need to build an HTTP tool.
As for guzzle, add in your Composer.json, then update

"guzzlehttp/guzzle": "~5.3|~6.0"

All of Laravel ' s extensions----->composer!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: [email protected] and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.