Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Requests Laravel Package

rmccue/requests

Requests is a human-friendly PHP HTTP client for sending GET/POST/PUT/DELETE/PATCH/HEAD requests with headers, auth, files, and parameters. Supports cURL or fsockopen, SSL verification, decompression, and IDN URLs with a consistent API.

View on GitHub
Deep Wiki
Context7

Custom Authentication

Custom authentication handlers are designed to be straight-forward to write. In order to write a handler, you'll need to implement the \WpOrg\Requests\Auth interface.

An instance of this handler can then be passed to Requests via the auth option, just like for normal authentication.

Let's say we have a HTTP endpoint that checks for the Hotdog header and authenticates the call if said header is set to Yummy. (I don't know of any services that do this; perhaps this is a market waiting to be tapped?)

class MySoftware_Auth_Hotdog implements \WpOrg\Requests\Auth {
    protected $password;

    public function __construct($password) {
        $this->password = $password;
    }

    public function register(\WpOrg\Requests\Hooks &$hooks) {
        $hooks->register('requests.before_request', array($this, 'before_request'));
    }

    public function before_request(&$url, &$headers, &$data, &$type, &$options) {
        $headers['Hotdog'] = $this->password;
    }
}

We then use this in our request calls like this:

$options = array(
    'auth' => new \MySoftware_Auth_Hotdog('yummy')
);
$response = \WpOrg\Requests\Requests::get('http://hotdogbin.org/admin', array(), $options);

For more information on how to register and use hooks, see the hooking system documentation.


Previous: Authenticating your request

Next: Requests through proxy

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope