Thread Hilfe bei Übersetzung aus PHP (5 answers)
Opened by bianca at 2021-07-24 09:15

bianca
 2021-07-24 09:15
#193445 #193445
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
Guten Morgen!

Es geht hier um die Abfrage von Herstellern über die MAC eines Gerätes. Ich habe dafür diesen Code auf MACVendors gefunden:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$mac_address = "FC:FB:FB:01:FA:21";

$url = "https://api.macvendors.com/" . urlencode($mac_address);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if($response) {
echo "Vendor: $response";
} else {
echo "Not Found";
}
?>


Das habe ich so übersetzt:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;

my $mac_address = 'FC:FB:FB:01:FA:21';

$mac_address =~ s/:/-/g;
my $url = "https://api.macvendors.com/$mac_address";
say $url;

require LWP::UserAgent;
my $ua = LWP::UserAgent->new(
    timeout         => 5,
);
my $response = $ua->get($url);

if ($response->is_success) {
    print $response->decoded_content;
}
else {
    die $response->status_line;
}


Aber was immer ich noch probiere liefert immer nur
Quote
403 Forbidden at test_vendorabfr.pl line 22.

Was mache ich falsch?
10 print "Hallo"
20 goto 10

View full thread Hilfe bei Übersetzung aus PHP