File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22
33require __dir__.'/vendor/autoload.php ' ;
4- use Supabase \Client ;
54
6- $ client = Client::connect ();
7- $ client ->setURL ('https://supabase.co ' );
8- $ client ->setApiKey ('fsvbg ' );
5+ use Dotenv \Dotenv ;
6+
7+ $ dotenv = Dotenv::createImmutable (__DIR__ );
8+ $ dotenv ->load ();
9+
10+ $ url = $ _ENV ['SB_URL ' ];
11+ $ key = $ _ENV ['SB_API_KEY ' ];
12+
13+ $ url2 = $ url ."/rest/v1/users?select=* " ;
14+
15+ $ ch = curl_init ();
16+ curl_setopt ($ ch , CURLOPT_URL , $ url2 );
17+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
18+ $ header = [
19+ 'Content-Type: application/json ' ,
20+ "apikey: $ key " ,
21+ "Authorization: Bearer $ key " ,
22+ ];
23+ curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ header );
24+
25+ $ result = curl_exec ($ ch );
26+ $ data = json_decode ($ result , true );
27+
28+ print ('<pre> ' );
29+ print_r ($ data );
30+ print ('</pre> ' );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Fetch \Interfaces \Response as ResponseInterface ;
4+
5+ $ data = null ;
6+
7+ async (fn () => fetch ()
8+ ->baseUri ('https://example.com ' )
9+ ->withHeaders ('Content-Type ' , 'application/json ' )
10+ ->withBody (['key ' => 'value ' ])
11+ ->withToken ('fake-bearer-auth-token ' )
12+ ->post ('/posts ' ))
13+ ->then (fn (ResponseInterface $ response ) => $ data = $ response ->json ()) // Success handler
14+ ->catch (fn (Throwable $ e ) => $ e ->getMessage ()); // Error handler
15+
16+ echo $ data ;
17+
18+ use Fetch \Interfaces \Response as ResponseInterface ;
19+
20+ $ data = null ;
21+
22+ async (fn () => fetch ()
23+ ->baseUri ('https://example.com ' )
24+ ->withQueryParameters (['page ' => 1 ])
25+ ->withToken ('fake-bearer-auth-token ' )
26+ ->get ('/resources ' ))
27+ ->then (fn (ResponseInterface $ response ) => $ data = $ response ->json ()) // Success handler
28+ ->catch (fn (Throwable $ e ) => $ e ->getMessage ()); // Error handler
29+
30+ echo $ data ;
You can’t perform that action at this time.
0 commit comments