File tree 3 files changed +13
-4
lines changed
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 24
24
*/
25
25
use Illuminate \Support \Facades \DB ;
26
26
27
+ use Illuminate \Support \Facades \Http ;
27
28
use IXP \Models \Customer ;
28
29
/**
29
30
* Artisan command to update the in_peeringdb flag of members
@@ -59,12 +60,18 @@ class InManrs extends Command
59
60
public function handle (): int
60
61
{
61
62
// get list of peeringdb networks:
62
- if ( !( $ json = file_get_contents ( 'https://www.manrs.org/wp-json/manrs/v1/asn ' ) ) ) {
63
- $ this ->error ( 'Could not load ASNs via MANRS \'s API ' );
63
+ try {
64
+ $ resp = Http::withHeaders ( [
65
+ 'X-Request-Client ' => 'IXP Manager ' ,
66
+ 'X-Request-Client-Version ' => APPLICATION_VERSION ,
67
+ ] )->throw ()->acceptJson ()
68
+ ->get ( 'https://api.manrs.org/asns ' );
69
+ } catch (\Exception $ e ) {
70
+ $ this ->error ( 'Could not load ASNs via MANRS \'s API: ' . $ e ->getMessage () );
64
71
return 1 ;
65
72
}
66
73
67
- $ asns = json_decode ( $ json , true ) ;
74
+ $ asns = $ resp [ ' asns ' ] ;
68
75
69
76
if ( !is_array ( $ asns ) || !count ( $ asns ) ) {
70
77
$ this ->error ( 'Empty or no ASNs returned from MANRS \'s API ' );
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ require __DIR__.'/vendor/autoload.php';
21
21
22
22
$ app = require_once __DIR__ .'/bootstrap/app.php ' ;
23
23
24
+ require_once base_path () . '/version.php ' ;
25
+
24
26
/*
25
27
|--------------------------------------------------------------------------
26
28
| Run The Artisan Application
Original file line number Diff line number Diff line change 81
81
82
82
$ app = require_once __DIR__ .'/../bootstrap/app.php ' ;
83
83
84
- include base_path () . '/version.php ' ;
84
+ require_once base_path () . '/version.php ' ;
85
85
86
86
$ kernel = $ app ->make ( Kernel::class );
87
87
You can’t perform that action at this time.
0 commit comments