开发者

problem with JAX-RS and foursquare

I don't know why I can't u开发者_JAVA百科se the MultivaluedMap here, can someone help. Eclipse is giving me that it can't be resolved into a type

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;

import javax.net.ssl.SSLContext;

import com.sun.jersey.api.client.*;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.Filterable;
import com.sun.jersey.core.util.MultivaluedMapImpl;

public class Main { 


    public static void main(String[] args) throws Exception {

        Client client = Client.create();
        WebResource webResource = client.resource("http://api.foursquare.com/v1/venues");
        MultivaluedMap queryParams = new MultivaluedMapImpl();
        queryParams.add("geolat", "51.543724");
        queryParams.add("geolong", "-.102365");
        String s = webResource.queryParams(queryParams).get(String.class);

    }
}

What other stuff am I missing here


You need the jsr jar on your classpath. If you're using Maven you can add:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
</dependency>

<repository>
    <id>java.maven2</id>
    <url>http://download.java.net/maven/2/</url>
</repository>

or you can download the jar and add it manually:

http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.1.1/

Re: authentication, you should look at the FourSquare documentation:

http://groups.google.com/group/foursquare-api/web/api-documentation

http://groups.google.com/group/foursquare-api/web/oauth


You didn't post the actual error message you get, so I have to resort to reading your mind, but you are also missing an import for MultivaluedMap. Shouldn't you add this:

import javax.ws.rs.core.MultivaluedMap;

?

If this is simply a compilation issue then it has nothing to do with foursquare but simply errors in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜