Autor Beitrag
colaka
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Di 21.07.09 06:45 
Hallo,

ich habe ein Programm, das über eine IdHTTP-Komponente die Artikellisten von verschiedenen Großhändlern herunterlädt und in meiner Artikeldatei die Preise aktualisiert. Ein Großhändler hat mir auf Anfrage jetzt das folgende PHP-Script geschickt:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
<?
  $fh=fopen("preisliste.csv","w");

  $file="http://<kundennummer>:<passwort>@www.api.de/db2/v2gesamtpreisliste.php?art=csv";
  $fr=fopen($file,"r");

  while($str=fread($fr,4096)) {
    fwrite($fh,$str);
  }

  fclose($fh);
  fclose($fr);
?>

Leider kenne ich mich mit PHP überhaupt nicht aus, aber wenn ich die in dem Script enthaltene Adresse in meinen Browser kopiere, erhalte ich die gewünschte Datei. Also müsste das doch auch per IdHTTP funktionieren. Ich schreibe also:
ausblenden Delphi-Quelltext
1:
IdHTTP.Get('http://<kundennummer>:<passwort>@www.api.de/db2/v2gesamtpreisliste.php?art=csv', Datei);					

Doch das funktioniert nicht. Ich habe es schon mit und ohne BasicAuthentication probiert. Und ich habe auch schon den Ausdruck "v2gesamtpreisliste.php?art=csv" mit "preisliste.csv" ersetzt.

Meine Frage: Geht das überhaupt mit IdHTTP oder sollte ich besser eine andere (welche?) Komponente verwenden?

Danke Ebi

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt


Zuletzt bearbeitet von colaka am Mi 22.07.09 06:50, insgesamt 1-mal bearbeitet
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 21.07.09 11:04 
Das ist Authentifizierung über HTTP. Trag Kundennummer und Passwort mal als Authentifizierungsparameter in IdHTTP ein und lass die in der URL weg.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
colaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 4

Win XP, W7
Delphi 2005 Prof.
BeitragVerfasst: Mi 22.07.09 06:51 
Danke, das hat funktioniert