tags:

views:

18

answers:

2

I don't know why I can't use 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

+1  A: 

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.

matt b
when I add that it says that javax.ws can't be resolved
EquinoX
I think there's also a problem with foursquare authentication, I am not sure on how to do basic authentication for foursquare in java
EquinoX
well that is a separate problem. Make sure the jax-ws JARs are on your classpath.
matt b
I did have the jersey-bundle.jar as part of the source..
EquinoX
+2  A: 

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/&lt;/url&gt;
</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

hisdrewness