2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

GetHttpFile -> GetFileFromURL change

git-svn-id: https://svn.fhem.de/fhem/trunk@1629 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-06-20 07:16:29 +00:00
parent e79c845b11
commit 60d2269a6c
5 changed files with 16 additions and 4 deletions

View File

@ -12,6 +12,7 @@ use strict;
use warnings; use warnings;
use GD; use GD;
use vars qw(%data); use vars qw(%data);
use HttpUtils;
# we can # we can
# use vars qw(%FW_types); # device types, # use vars qw(%FW_types); # device types,
@ -232,7 +233,7 @@ RSS_itemGif {
return if($host eq ""); return if($host eq "");
return if($filename eq ""); return if($filename eq "");
($x,$y)= RSS_xy($S,$x,$y); ($x,$y)= RSS_xy($S,$x,$y);
my $data = GetHttpFile($host,$filename); my $data = GetFileFromURL("http://$host$filename");
return unless(defined($data)); return unless(defined($data));
my $I= GD::Image->newFromGifData($data); my $I= GD::Image->newFromGifData($data);
my ($width,$height)= $I->getBounds(); my ($width,$height)= $I->getBounds();

View File

@ -46,6 +46,7 @@ use strict;
use warnings; use warnings;
use Data::Dumper; use Data::Dumper;
use IO::Socket; use IO::Socket;
use HttpUtils;
use constant PARAM_NAME => 1; use constant PARAM_NAME => 1;
use constant PARAM_HOST => 2; use constant PARAM_HOST => 2;
@ -120,7 +121,7 @@ NetIO230B_Request($@)
my $URL=''; my $URL='';
my $log=''; my $log='';
my $response = GetHttpFile($hash->{HOST}.":80","/tgi/control.tgi?l=p:". $hash->{USER}.":".$hash->{PASS}."&p=l"); my $response = GetFileFromURL("http://".$hash->{HOST}."/tgi/control.tgi?l=p:". $hash->{USER}.":".$hash->{PASS}."&p=l");
if(!$response or length($response)==0) if(!$response or length($response)==0)
{ {
Log 3, "NetIO230B_Request failed: ".$log; Log 3, "NetIO230B_Request failed: ".$log;

View File

@ -8,6 +8,7 @@ package main;
use strict; use strict;
use warnings; use warnings;
use POSIX; use POSIX;
uset HttpUtils;
sub dayofyear { sub dayofyear {
my ($day1,$month,$year)=@_; my ($day1,$month,$year)=@_;
@ -274,7 +275,7 @@ sub Twilight_getWeatherHorizon{
#condition codes are described in FHEM wiki and in the documentation of the yahoo weather API #condition codes are described in FHEM wiki and in the documentation of the yahoo weather API
my $hash=shift; my $hash=shift;
my $location=$hash->{WEATHER}; my $location=$hash->{WEATHER};
my $xml = GetHttpFile("weather.yahooapis.com:80","/forecastrss?w=".$location."&u=c",4.0); my $xml = GetFileFromURL("http://weather.yahooapis.com/forecastrss?w=".$location."&u=c",4.0);
my $current; my $current;
if($xml=~/code="(.*)"(\ *)temp/){ if($xml=~/code="(.*)"(\ *)temp/){
if(defined($1)){ if(defined($1)){

View File

@ -120,7 +120,7 @@ sub Weather_RetrieveDataDirectly($)
my $lang= $hash->{LANG}; my $lang= $hash->{LANG};
my $fc = undef; my $fc = undef;
my $xml = GetHttpFile("www.google.com:80", "/ig/api?weather=" . $location . "&hl=" . $lang); my $xml = GetFileFromURL("http://www.google.com/ig/api?weather=" . $location . "&hl=" . $lang);
return 0 if($xml eq ""); return 0 if($xml eq "");
foreach my $l (split("<",$xml)) { foreach my $l (split("<",$xml)) {
#Log 1, "DEBUG WEATHER: line=\"$l\""; #Log 1, "DEBUG WEATHER: line=\"$l\"";

View File

@ -83,4 +83,13 @@ GetFileFromURL($@)
return $ret; return $ret;
} }
##################
# Compatibility mode
sub
GetHttpFile($$)
{
my ($host,$port) = @_;
return GetFileFromURL("http://$host$file);
}
1; 1;