NSURL *pictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookID]];
NSString *urlString = [pictureURL absoluteString];
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
// result is a dictionary with the user's Facebook data
NSDictionary *userData = (NSDictionary *)result;
NSString *facebookID = userData[@"id"];
NSURL *pictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookID]];
NSString *urlString = [pictureURL absoluteString];
NSLog(@"sting=%@",urlString);
PFUser *me = [PFUser currentUser];
me[@"facebookId"] = userData[@"id"];
me["pictureURL"] = userData[urlString];
me[@"username"] = userData[@"name"];
[me saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (error) {
NSLog(@"Error to store=%@",error.localizedDescription);
}
}];
[self presentViewController:push animated:YES completion:nil];
} else {
[self presentViewController:push animated:YES completion:nil];
}
}];
Uygulamamda herhangi bir yeni kullanıcı oturum açtığında Facebook Resmi veya URL'sini kaydetmem gerekiyor. AFAIK biz url'yi doğrudan NSString'e dönüştürmeyi denemedik ama sonra hata attı "'PFObject'de anahtarlar veya değerler için sıfır kullanamazsınız. Değerler için NSNull kullanın.'"Kaydetme Resim/URL in Parse DB
Herhangi bir yol var mı Görüntüyü doğrudan Parse olarak kaydetmek için bu linki veya başka bir alternatif yolu saklayabileceğim şekilde mi?
Soruna gerçekten neden olan kodu göstermek için sorunuzu güncelleştirmelisiniz. – rmaddy
Yukarıdaki kodu güncelledi. Lütfen kontrol edin. –