save to codehub
This commit is contained in:
35
app/Http/Controllers/Website/TransformBeyondController.php
Normal file
35
app/Http/Controllers/Website/TransformBeyondController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class TransformBeyondController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
|
||||
// $apiKey = "bdf20639fab33d6dc265da0f6926a491";
|
||||
// $ip = $request->ip(); // Get user's IP address
|
||||
|
||||
// $client = new Client();
|
||||
// $response = $client->get("http://api.ipstack.com/{$ip}?access_key={$apiKey}");
|
||||
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}?token=fb9b51b5a3bbd9");
|
||||
// Parse the JSON response
|
||||
$data = $response->json();
|
||||
// dd($data);
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// Get user's country code from the API response
|
||||
$userCountry['data'] = $data['country'];
|
||||
|
||||
// dd($userCountry);
|
||||
|
||||
return view('website.pages.transform_beyond',$userCountry);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user