我正在尝试获取使用Yelp Fusion API的访问令牌。我已经尝试了下面的POST请求,但是一直收到404错误。这是我第一次尝试发出POST请求,所以我不确定我做得是否正确。
我在这里附上了来自YELP的说明:https://www.yelp.com/developers/documentation/v3/authentication
提前谢谢。
public static final String YELPURL = "https://api.yelp.com/oauth/token";
public static void main(String[] args) {
try {
URL obj = new URL(YELPURL);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("grant_type", "client_credentials");
con.setRequestProperty("client_id", CLIENTID);
con.setRequestProperty("client_secret", CLIENTSECRET);
con.setDoOutput(true);
int responseCode = con.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}发布于 2017-06-18 14:48:15
https://stackoverflow.com/questions/44612431
复制相似问题