حالة الطقس ب دلفي api & json
#1
السلام عليكم
برنامج مفتوح المصدر يحتوي على حالة الطقس ووقت الغروب والشروق ...
يمكنكم استخدام الاحداثيات او اسم المدينة لايجاد المعلومات بالاضافة الى مفتاح وللحصول عليه اضغط هنا
مثلا
PHP كود :
q/37.336500,7.183000.json
او
q
/Batna.json 

[صورة: z5n9.png]

لعشرة ايام

[صورة: z55v.png]

الكود سورس

PHP كود :
uses
IdHTTP
,GIFImage,superobject, 
PHP كود :
procedure TForm1.loadgif(http: string;img:TImage);
var   
ms : TMemoryStream;
  
gif: TGIFImage;
begin
img
.Picture:=nil;
gif  := TGIFImage.Create;
ms := TMemoryStream.Create;
       try
       try
    
idhttp1.Get(http,ms);
   
///MS.Seek(0,soFromBeginning);
    
ms.Position:=0;
    
gif.LoadFromStream(ms);
    
img.Picture.Assign(gif);
    
except 
      end
;
      finally 
      
gif.Free;
      
ms.Free;
end;
end;

procedure TForm1.IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  
AWorkCount: Int64);
begin
Application
.ProcessMessages;
sgauge1.Progress:=AWorkCount;
end;

procedure TForm1.IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  
AWorkCountMax: Int64);
begin
sgauge1
.MaxValue:=AWorkCountMax;
end;

procedure TForm1.IdHTTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
sgauge1
.Progress:=0;
end;

procedure TForm1.FormShow(Sender: TObject);
var 
conditions,astronomy:string;

begin
  
try
conditions:=idhttp1.Get('http://api.wunderground.com/api/a08dd34c67819ee0/conditions/q/Batna.json');//&ip='+edt1.Text);
astronomy:= idhttp1.Get('http://api.wunderground.com/api/a08dd34c67819ee0/astronomy/q/Batna.json');

except
sLabelFX1
.Caption:=('Temperature :  0 C');
sLabelFX3.Caption:=('Station : Not Connected');
  
end;
if 
Length(conditions)=0 then Exit;
sLabelFX1.Caption:=('Temperature : '+so(conditions)['current_observation']['temperature_string'].AsString) ;
sLabelFX2.Caption:=('Location : '+so(conditions)['current_observation']['display_location']['full'].AsString) ;
sLabelFX3.Caption:=('Station : '+so(conditions)['current_observation']['icon'].AsString) ;
sLabelFX7.Caption:=(so(conditions)['current_observation']['temp_c'].AsString+' C') ;
sLabelFX4.Caption:=('Weather : '+so(conditions)['current_observation']['weather'].AsString) ;
sLabelFX5.Caption:=('Relative Humidity : '+so(conditions)['current_observation']['relative_humidity'].AsString) ;
sLabelFX6.Caption:='Elevation : '+Format('%.6s',[(so(conditions)['current_observation']['display_location']['elevation'].AsString)]) ;
loadgif(so(conditions)['current_observation']['icon_url'].AsString,img1) ;
if 
Length(astronomy)=0 then Exit;
 
sLabelFX8.Caption:=(so(astronomy)['sun_phase']['sunrise']['hour'].AsString+':'+
 
so(astronomy)['sun_phase']['sunrise']['minute'].AsString) ;
 
sLabelFX9.Caption:=(so(astronomy)['sun_phase']['sunset']['hour'].AsString+':'+
 
so(astronomy)['sun_phase']['sunset']['minute'].AsString) ;

end;

procedure TForm1.sSpeedButton1Click(Sender: TObject);
var 
forecast10day:string;
i:Byte;
begin
  
try
  
forecast10day:=idhttp1.Get('http://api.wunderground.com/api/a08dd34c67819ee0/forecast10day/q/Batna.json');
 if 
Length(forecast10day)=0 then Exit;
 for 
i:=0 to 19 do
   
with form2.sListView1.Items.Add do begin
    Caption
:=so(forecast10day)['forecast']['txt_forecast']['forecastday['+inttostr(i)+'].title'].AsString ;
        
SubItems.Add(so(forecast10day)['forecast']['txt_forecast']['forecastday['+inttostr(i)+'].fcttext'].AsString) ;
        
SubItems.Add(so(forecast10day)['forecast']['txt_forecast']['forecastday['+inttostr(i)+'].icon'].AsString) ;
        
SubItems.Add(so(forecast10day)['forecast']['txt_forecast']['forecastday['+inttostr(i)+'].fcttext_metric'].AsString) ;

                                
end;
                                
except
                                  end
;

form2.show;
end; 
الرد
#2
شكراّ ..أخى الكريم على هذا الطرح العظيم...!!!
الرد
#3
ها هو البرنامج ^_^ برمجته ليشبهه كثيراا
المرجو التوفر على مكونات AlphaControl (AlphaSkins)
ادا لم تكن تتوفر عليها حملها من alphaskins.com


الملفات المرفقة
.rar   Project.rar (الحجم : 111.11 ك ب / التحميلات : 206)
الرد
#4
TheGame كتب :ها هو البرنامج ^_^ برمجته ليشبهه كثيراا
المرجو التوفر على مكونات AlphaControl (AlphaSkins)
ادا لم تكن تتوفر عليها حملها من alphaskins.com
لا اعلم كيف تفكر لاكن استخدمت الكود الذي برمجته ووضعت عليه اسمك ؟؟؟
'Ess-Soft © 2014 │ ess-soft.net';
الرد
#5
أستسمح يا أخي لكنني فقط كتبت دلك لكنني لم أنشر البرنامج في مكان أخر غير هدا المنتدى و الكل يعرف أنك صاحب البرنامج الاصلي و أستسمح تانية كانت نيتي هي أن احاول صنع مثله لاجل الاعضاء الذين لم يتمكنو من عمل compile وليس أن أقول انني صاحب الكود الاصلي و شكرا لتفهمك ان نيتي كانت الـمسـاعدة و ليس سرقة السورس.
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم