问题描述
我在iOS应用程序中将facebook sdk用于登录和user_photos.
I am using the facebook sdk for login and user_photos purpose in a iOS Application.
登录已完成,并在权限中添加了user_photos
readPermissions
.
The login is done and in the permissions I added the user_photos
readPermissions
.
但是,当我尝试使用graphPath:me/具有fields
参数-id,picture
的照片来获取用户照片时,仅返回最小的图像大小.我尝试使用picture.type(large)
或picture.width(640)
,但是没有任何效果.
But when I am trying to fetch the user photos using the graphPath: me/photos with fields
parameters- id,picture
, only the smallest of the images size is returned. I have tried using picture.type(large)
or picture.width(640)
, but nothing works.
我尝试对fields
使用images
参数,它返回Photo节点的所有大小.
I tried using the images
parameter for fields
, it returns all the sizes for the Photo node.
我什至尝试将边缘<OBJECT_ID>/picture
与fields
参数picture
一起使用,但是它给出了facebook sdk error(error code 6)
.
I even tried using the edge <OBJECT_ID>/picture
with fields
parameter picture
, but it gives a facebook sdk error(error code 6)
.
如何仅通过单个照片链接将用户照片放大为大尺寸?
How to get the user photos with just a single photo link to a large size ?
我正在使用最新版本的SDK.
I am using the latest version of the SDK.
推荐答案
Swift-试试这个
@IBAction func facebookLoginButtonTapped(_ sender: UIButton) {
let fbLoginManager: FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.logIn(withReadPermissions: ["email", "pages_show_list"], from: self) { (result, error) in
if (error == nil){
let fbLoginResult: FBSDKLoginManagerLoginResult = result!
if fbLoginResult.grantedPermissions != nil {
if(fbLoginResult.grantedPermissions.contains("email")){
self.facebookLogin()
}
}
}
}
}
}
func facebookLogin() {
if((FBSDKAccessToken.current()) != nil) {
FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id, name, first_name, last_name, picture.type(large), email "]).start(completionHandler: { (connection, result, error) in
if result == nil {
}
else{
self.userResults = result as! [String : AnyObject]
self.email = (self.userResults["email"] as? String) ?? ""
if (self.email != "") {
let url = URL(string: "http://graph.facebook.com/\(YOURE FACEBOOK ID)/picture?type=large")!
let session = URLSession(configuration: .default)
let downloadPicTask = session.dataTask(with: url) { (data, response, error) in
// The download has finished.
if let e = error {
print("Error downloading cat picture: \(e)")
} else {
if let res = response as? HTTPURLResponse {
print("Downloaded cat picture with response code \(res.statusCode)")
if let imageData = data {
let image: UIImage = UIImage(data: imageData)!
} else {
print("Couldn't get image: Image is nil")
}
} else {
print("Couldn't get response code for some reason")
}
}
}
downloadPicTask.resume()
}
else{
Utility.showAlert("Login Faild", message: error?.localizedDescription, viewController: self)
}
}
})
}
}
这篇关于无法为Facebook Graph API用户的照片边缘获得单个大尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!