2013-04-25 6 views
2

야후 날씨 포 캐스트가 가장 유용하다는 사실을 발견했습니다.Yahoo의 시간별 일기 예보 API에 전화를 걸려면 어떻게해야합니까?

야후의 날씨 요청은 here입니다.

Yahoo API 호출 http://weather.yahooapis.com/forecastrss?w=2502265을 사용하여 위의 시간별 날씨 예보에 대한 API 요청을 어떻게 만들 수 있습니까?

This is the documentation I found.

+1

RSS 피드를 호출하는 데 사용하려는 도구는 무엇입니까? 웹 페이지 또는 데스크톱 응용 프로그램 (또는 다른 것)에 표시 하시겠습니까? – snumpy

+0

날씨를 시간별로 표시하는 웹 응용 프로그램을 개발하려면 http://developer.yahoo.com/weather에 가장 적합한 야후 날씨 API를 찾아야하지만 [link] (http://in.weather.com/weather/hourByHour-INXX0104? cm_ven = yahoo_in & cm_cat = citypage & cm_ite = weather & cm_pla = 매시간) yhoo api를 매시간 날씨로 호출 할 수있는 방법은 무엇입니까? – anu

+0

# yahoo-weather-api – Rolan

답변

0

사용하려는 프로그래밍 언어의 REST API를 사용하여 수행 할 수 있습니다. Java 예제를 제공합니다. (비슷한 일이 너무 다른 언어에 적용됩니다 ..) '

package tests; 

import org.apache.http.*; 
import org.apache.http.client.methods.HttpGet; 
import org.apache.http.impl.client.DefaultHttpClient; 
import org.apache.http.util.EntityUtils; 

/** 
* A simple Java REST GET example using the Apache HTTP library. 
* This executes a call against the Yahoo Weather API service, which is 
* actually an RSS service (http://developer.yahoo.com/weather/). 
* 
* Try this Twitter API URL for another example (it returns JSON results): 
* http://search.twitter.com/search.json?q=%40apple 
* (see this url for more twitter info: https://dev.twitter.com/docs/using-search) 
* 
* Apache HttpClient: http://hc.apache.org/httpclient-3.x/ 
* 
*/ 
public class ApacheHttpRestClient1 { 

    public static void main(String[] args) { 
    DefaultHttpClient httpclient = new DefaultHttpClient(); 
    try { 
     // specify the host, protocol, and port 
     HttpHost target = new HttpHost("weather.yahooapis.com", 80, "http"); 

     // specify the get request 
     HttpGet getRequest = new HttpGet("/forecastrss?p=80020&u=f"); 

     System.out.println("executing request to " + target); 

     HttpResponse httpResponse = httpclient.execute(target, getRequest); 
     HttpEntity entity = httpResponse.getEntity(); 

     System.out.println("----------------------------------------"); 
     System.out.println(httpResponse.getStatusLine()); 
     Header[] headers = httpResponse.getAllHeaders(); 
     for (int i = 0; i < headers.length; i++) { 
     System.out.println(headers[i]); 
     } 
     System.out.println("----------------------------------------"); 

     if (entity != null) { 
     System.out.println(EntityUtils.toString(entity)); 
     } 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } finally { 
     // When HttpClient instance is no longer needed, 
     // shut down the connection manager to ensure 
     // immediate deallocation of all system resources 
     httpclient.getConnectionManager().shutdown(); 
    } 
    } 

가 동일한 작업을 수행하기 위해 더 많은 방법이 있습니다 ... 당신이하지 않는 것 http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples

+0

그 큰 도움 오라 .. 나는 램프 플랫폼에 있습니다. ..thanks – anu

+0

여기를 클릭하면 페이지에서 [링크] (http://in.weather.yahoo.com/united-states/maryland/california-2373278/)가 매시간 클릭됩니다. 시간별 날씨 정보를 볼 수 있습니다. 우리가 forcastrss로 요청할 수있는 방법을 알고 싶습니다. (http://weather.yahooapis.com/forecastrss?w=2442047&u=c) [Link] (http://developer.yahoo.com/weather /) – anu

+0

네, 당신은 http://developer.yahoo.com/weather/#req에서 주어진 것처럼 forcastrss 요청을 할 수도 있습니다. – AurA

0

야후 날씨 API 광고에서 다른 많은 다른 방법을 찾을 수 있습니다 (woeid) 또는 (lat, long) 및 온도 단위 (u 또는 f)와 같은 위치를 제어 할 수있는 몇 가지 매개 변수가 있습니다. 야후 쿼리 언어는 here을 참조하십시오.

다른 api의 AccuWeather을 시간별로 사용할 수 있습니다.

관련 문제