GWT를 사용하여 페이스 북 플랫폼 웹 앱을 만들고 App Engine에 호스팅하고 있습니다.
제공된 쿼리 문자열 매개 변수를 콜백 URL에 사용하는 유효성 검사 코드를 추가하고 있습니다. GWT를 사용하면 Window.Location.getParameterMap()을 호출하여 이러한 매개 변수를 가져올 수 있으며 반환 된 Map은 변경되지 않습니다.
하지만이 문제는 FB, GWT 또는 App Engine과는 아무런 관련이 없으며 Map 객체에 대한 내 오해에 더 가깝다고 생각합니다.
내 코드가 제공된 맵을 수정하려고 시도하지 않았지만 얻은 오류로 인해 내 코드가 변경 불가능한 맵을 수정하려고 시도하는 것 같습니다.
수정할 수없는지도를 수정하고 싶은 사람이 있습니까?
스택 추적을 제공 하겠지만 스택 추적을 통해 App Engine 로그에 표시 할 수있는 방법을 찾을 수 없습니다. 일체의 사전에
덕분에 :-)
/**
* Validation Test
* To generate the signature for these arguments:
* 1. Remove the fb_sig key and value pair.
* 2. Remove the "fb_sig_" prefix from all of the keys.
* 3. Sort the array alphabetically by key.
* 4. Concatenate all key/value pairs together in the format "k=v".
* 5. Append your secret key.
* 6. Take the md5 hash of the whole string.
* @param fbQueryStringParams
* @return String
*/
public String test(Map<String,List<java.lang.String>> fbQueryStringParams) {
String appSecret = TinyFBClient.APP_SECRET;
String fbSig = fbQueryStringParams.get("fb_sig").get(0);
StringBuilder sb = new StringBuilder();
TreeMap<String,String> sortedMap = new TreeMap<String,String>();
// Get a Set view of the Map of query string parameters.
Set<Map.Entry<String,List<java.lang.String>>> mapEntries = fbQueryStringParams.entrySet();
// Iterate through the Set view, inserting into a SortedMap all Map.Entry's
// that do not have a Key value of "fb_sig".
Iterator<Map.Entry<String,List<java.lang.String>>> i = mapEntries.iterator();
while(i.hasNext()) {
Map.Entry<String,List<java.lang.String>> mapEntry = i.next();
if(!mapEntry.getKey().equals("fb_sig")) { // 1. Remove the fb_sig key and value pair.
sortedMap.put(mapEntry.getKey(),mapEntry.getValue().get(0)); // 3. Sort the array alphabetically by key.
}
}
// Get a Set view of the Map of alphabetically sorted Map.Entry objects.
Set<Map.Entry<String,String>> sortedMapEntries = sortedMap.entrySet();
// Iterate through the Set view, appending the concatenated key's and value's
// to a StringBuilder object.
Iterator<Map.Entry<String,String>> ii = sortedMapEntries.iterator();
while(ii.hasNext()) {
Map.Entry<String,String> mapEntry = ii.next();
// 4. Concatenate all key/value pairs together in the format "k=v".
sb.append(mapEntry.getKey().replaceAll("fb_sig_","")); // 2. Remove the "fb_sig_" prefix from all of the keys.
sb.append("=");
sb.append(mapEntry.getValue());
}
sb.append(appSecret); // 5. Append your secret key.
String md5 = DigestUtils.md5Hex(sb.toString()); // 6. Take the md5 hash of the whole string.
// Build and return an output String for display.
StringBuilder output = new StringBuilder();
output.append("fbSig = "+fbSig);
output.append("<br/>");
output.append("md5 = "+md5);
return output.toString();
}
또한 오류 메시지를 게시하고 불만을 제기하는 행을 표시하십시오. –
은 괜찮아 보이지만 어떤 맵은 변경 불가능한 맵입니까? 메서드의 매개 변수는 무엇입니까? –
죄송합니다,이 사이트를 처음 사용했기 때문에 귀하는 의견을 남기 셨습니다. 전체 오류 메시지와 줄은 완벽하지만 "java.util.Collections $ UnmodifiableMap"을 생성하는 Throwable.getMessage()를 제쳐두고 유용한 것을 얻으려고 애 쓰고 있습니다. 그게 전부에요. 또한 메서드에 대한 매개 변수는 수정할 수 없습니다. 난 항상 그것을 (문서에) 알았지 만 내 코드가 우연히지도를 수정하려고했는지 확실하지 않았습니다. 귀하의 의견에 감사드립니다 :-) – Darren