2
我讀了Facebook文檔並實現了我的代碼,但請求沒有發送。我無法在網站上看到請求通知。我可以在我的日誌屏幕上看到請求ID。通過應用程序發送Facebook請求
這裏是我的部分代碼: 我從developer.facebook.com
+ (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:@"="];
NSString *val =
[kv[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
params[kv[0]] = val;
}
return params;
}
+(void) requestFriendMethod{
// Display the requests dialog
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:@"message"
title:@"title"
parameters:nil
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or sending the request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
// Handle the send request callback
NSDictionary *urlParams = [AKFacebook parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"request"]) {
// User clicked the Cancel button
NSLog(@"User canceled request.");
} else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:@"request"];
NSLog(@"Request ID: %@", requestID);
}
}
}
}];
}
我在做什麼錯誤代碼?感謝您的回答和建議。
我已經嘗試過此代碼,但它也不發送請求。也許正如你所說,它可以是沙箱模式。感謝您的回答 –
雅,請檢查沙箱模式。如果我的答案可以幫助你,upvote和接受。 – Ramdy