Support the ongoing development of Laravel.io →
Authentication Requests

Hi friends. Can you tell me how to know from which server/site I get curl request?

The story is something like that: I have API for some data. Users can get that data using query with API key. But in server (API) side I must detect is that valid key for user who send curl request to my API. How to do that? Did I need some more variables like secret key or something and how to do that?

API is in Laravel5 and use MySQL database.

Last updated 3 years ago.
0

Hi,

I never did this so maybe somebody will have a better answer.

But i know you can check the origin of the request in the headers.

$request->header('origin');

Then check if secret key match domain.

Last updated 10 years ago.
0

Origin returns me a null. API key unique but user can use that key in many sites, so I want disable it option.

0

My bad it's not origin, try with

$request->header('Host');

You can check headers in chrome inspector, look at a javascript request for example ;)

Last updated 10 years ago.
0

It returns me a API url. Maybe it helps, I call curl on this way:

$query['appkey'] = 'some lenght key';
$str = '';
foreach($query as $k => $v)
     $str .= $k.'='.$v.'&';
$ch = curl_init();
$url = "http://apiwebsite/api/data?" . $str;
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
curl_close($ch);
Last updated 10 years ago.
0

Hmmm,

did you tried with

$request->header('referer');
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.