Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 22:04

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Simple HTTP GET Request mit Headers?

Discussion on Simple HTTP GET Request mit Headers? within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
BlueBasHeR's Avatar
 
elite*gold: 25
Join Date: Nov 2011
Posts: 266
Received Thanks: 60
Question Simple HTTP GET Request mit Headers?

Hey, vorab ich hab die SuFu genutzt aber aus verzweifelung copy & paste ich alles durch und bekomme kein ergebnis...


Mein Projekt:
Ich lasse auf meinem IPhone Siri Shortcuts laufen, an sich funktioniert alles und zwar handelt es sich einfach um eine Bildersuche, wo dann mehrere Bilder angezeigt werden und man soll dann mit einem Submit Button pro bild quasi ein Like geben können.

auf dem IPhone in der Kurzbefehle app mit "Inhalte von Website" abrufen "Methode: GET" und 4 Headers die man immer Benötigt!
1. X-AUTH-TOKEN = (Mein Token ist Vorhanden.)
2. Content-Type = Application/json
3. Accept = Application/json
4. Platform = Web
funktioniert alles Perfekt.

Wieso ich dann alles über JS machen möchte?
Weil ich im IPhone mit JS und HTML eine Locale Website anzeigen kann die man dann Gestaltet wie man möchte und der Code ist definitiv viel Kürzer...

Nochmal in Kurzform:
Ich brauche irgend eine Möglichkeit JS in einem Simplen HTTP Code auszuführen in einem "<script></script>" Block. (Ja es funktioniert in der Kurzbefehle app !)

Xhr oder Fetch eigentlich egal muss nur
GET auch vorhanden)
Header: oben aufgelistet..

danke im vorraus, ich weiss ich hab es umständlich geschildert, bin aufm weg zur arbeit
BlueBasHeR is offline  
Old 07/20/2022, 23:05   #2
 
Valomirant's Avatar
 
elite*gold: 5
Join Date: Jul 2022
Posts: 23
Received Thanks: 1
Schau dir Fetch an o:
Valomirant is offline  
Old 08/05/2022, 13:47   #3
 
elite*gold: 4
Join Date: Dec 2010
Posts: 4,733
Received Thanks: 3,870
Wurzelhüpfer is offline  
Old 08/05/2022, 14:00   #4

 
R3D*'s Avatar
 
elite*gold: 190
Join Date: May 2011
Posts: 1,204
Received Thanks: 832
Did you try to use fetch method?
R3D* is offline  
Old 08/05/2022, 16:24   #5
 
Hyukisawa's Avatar
 
elite*gold: 133
Join Date: May 2007
Posts: 506
Received Thanks: 194
Mit fetch

Code:
const fetchURL = async (url) => {
    const response = await fetch(url, {
        method: "GET",
        headers: {
            "X-AUTH-TOKEN": "myToken",
            "Content-Type": "Application/json",
            "Accept": "Application/json",
            "Platform": "Web"
        }
    })
    const data = await response.json();

    // do stuff with data;
    
}

fetchURL("https://api.website.com/like/123456789");
Hyukisawa is offline  
Old 02/07/2023, 16:54   #6
 
elite*gold: 0
Join Date: Feb 2023
Posts: 2
Received Thanks: 2
Here is an example of a simple HTTP GET request with headers using Python:
makefile
import requests url = "https://www.example.com" headers = { "User-Agent": "My User Agent", "Accept-Language": "en-US" } response
akatema92 is offline  
Thanks
2 Users
Old 05/09/2023, 18:51   #7
 
gulshan212's Avatar
 
elite*gold: 0
Join Date: Apr 2023
Posts: 5
Received Thanks: 0
Hello this is Gulshan Negi
Well, to execute JavaScript in a simple HTTP code, you can use the Fetch API. Here's an example code snippet that shows how you can use Fetch to make a GET request to the URL you provided with the headers you listed:

fetch('https://api.website.com/like/123456789', {
method: 'GET',
headers: {
'X-AUTH-TOKEN': 'your-token-value',
'Content-Type': 'application/json',
'Accept': 'application/json',
'Platform': 'Web'
}
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error('Network response was not ok.');
}
})
.then(data => {
console.log(data); // handle response data here
})
.catch(error => {
console.error('Error:', error);
});

Thanks
gulshan212 is offline  
Reply

Tags
headers, html, js, request


Similar Threads Similar Threads
FF Live Http Headers funktioniert nicht
03/16/2012 - Off Topic - 0 Replies
Hallo, habe mir heute das Addon für FireFox heruntergeladen. Nur leider geht es nicht, immer wenn ich auf Einstellung drücke passiert nichts und ich kann nichts mehr bei FireFox drücken und muss den Prozess beenden. Habe schon meinen PC neugestartet und das neueste Update für FF installiert. Und kann das Addon auch nicht über Extras aufrufen, da es dort nicht aufgelistet ist. Ich hoffe mir kann jemand helfen. Grüße edit: Habe gerade bemerkt das ich kein Addon unter Einstellung öffnen...
anderes programm als live http headers
10/19/2010 - General Coding - 2 Replies
hey wenn ich mich auf die-staemme.de einlogge, kommt keine nachricht bei live http headers (FF addon). gibts n anderes programm dafür, dass auch von Diestaemme ausliest? :handsdown::handsdown::handsdown::handsdown: edit keine http header nachrichten :-)



All times are GMT +1. The time now is 22:06.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.