1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help with Yahoo API

Discussion in 'Yahoo API' started by onentwoo, Mar 13, 2005.

  1. #1
    Greetings
    Well i am ready to give up - it taking me a lot of time learning how to use Yahoo API.
    after with forums help i realized that i need to download all kind of JAXB and JAXME jars.
    I finally was able to go without errors - until i got the :

    java.net.UnknownHostException: api.search.yahoo.com

    My program is simple (java one):

    try
    {
    SearchClient x = new SearchClient("myCode");
    WebSearchRequest u = new WebSearchRequest("test word");

    WebSearchResults z;
    WebSearchResult d;

    x.webSearch(u);
    d = z.listResults()[0];
    System.out.println(d.getTitle());
    }
    catch (SearchException v)
    {
    System.out.println(v.toString() );
    }
    catch (IOException v)
    {
    System.out.println(v.toString() );
    }


    So why does it throw this exception ? and how come others use it so quickly ?
    I don't remember having such a hard time with Google API.

    anyone know ?

    Thanx in advance
     
    onentwoo, Mar 13, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Do you really need to use Java as your mechanism to query the API? It's much easier to just make an HTTP request to it and you get nicely formatted XML as a result.
     
    digitalpoint, Mar 13, 2005 IP
  3. onentwoo

    onentwoo Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    However the java thing cover the XML for me so i do not use to do any analysis
    (like google api)

    I am not yet familiar with the XML mechanizm in java.

    However i'll be happy to see a sample how to work with the Yahoo API XML
    *there is an example in their site - but they do not show how to analyze the XML.

    Maybe this will be easier
     
    onentwoo, Mar 14, 2005 IP
  4. dobestself

    dobestself Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    I had a problem i was using Yahoo API .
    SearchClient client = new SearchClient("javasdktest");


    try{
    if("image".equals(type)){
    ImageSearchRequest searchRequest = new ImageSearchRequest(URLEncoder.encode(word, "UTF-8"));
    // 是否显示成人内容
    searchRequest.setAdultOk(adultOk);
    // 查询记录数
    searchRequest.setResults(20);
    // 从第 0 条记录开始显示
    searchRequest.setStart(BigInteger.valueOf(0));

    double startTime = System.currentTimeMillis();

    System.out.println("haha");
    ImageSearchResults results = client.imageSearch(searchRequest); the context colored could not go ,can anyone help me?
    Thanx in advance
     
    dobestself, Apr 19, 2014 IP
  5. ineedfreedom

    ineedfreedom Active Member

    Messages:
    42
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Agree with this guy, java van be a headache
     
    ineedfreedom, Apr 20, 2014 IP