我正在尝试获取使用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();
}
}
答案 0 :(得分:0)