我正在嘗試使用Facebook4J開發Facebook API。將facebook的access_token作爲流程獲得成功。使用Facebook4j Facebook api請求失敗
@RequestMapping(value="biztopia.facebook.redirectLogin.do")
public void redirectLogin(ModelMap model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
String code = request.getParameter("code");
Facebook facebook = (Facebook) request.getSession().getAttribute("facebook");
String oauthCode = request.getParameter("code");
try {
facebook.getOAuthAccessToken(oauthCode);
AccessToken token = facebook.getOAuthAccessToken();
response.sendRedirect("biztopia.facebook.requestUserInfo.do");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@RequestMapping(value="biztopia.facebook.requestUserInfo.do")
public void requestUserInfo(ModelMap model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
Facebook facebook = (Facebook) request.getSession().getAttribute("facebook");
try {
User user = facebook.getMe();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
收到EXCETION消息作爲流
FacebookException {的StatusCode = 400,響應=的HttpResponse {的StatusCode = 400,responseAsString ='{ 「錯誤」:{ 「消息」:「從服務器API調用需要一個appsecret_proof參數「,」type「:」GraphMethodException「,」code「:100}} ',[email protected]46f4515,streamConsumed = true},errorType ='GraphMethodException ',errorMessage ='來自服務器的API調用需要appsecret_proof參數',errorCode = 100,errorSubcode = -1}在facebook4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189) 噸facebook4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65) 在facebook4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93) 在facebook4j.FacebookImpl.get(FacebookImpl.java:2431) 在facebook4j.FacebookImpl.getMe(FacebookImpl.java:105) 在facebook4j.FacebookImpl.getMe(FacebookImpl.java:101) 在biztopia.facebook.web.FacebookController.requestUserInfo(FacebookController.java:292)