我使用以下代码.我想要用户的出生日期,电子邮件和性别.请帮忙.如何检索这些数据?
这是我onViewCreated()
在片段中的内容.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Setup TextView.
mTextDetails = (TextView) view.findViewById(R.id.text_details);
// Set up Login Button.
LoginButton mButtonLogin = (LoginButton) view.findViewById(R.id.login_button);
// setFragment only if you are using it inside a Fragment.
mButtonLogin.setFragment(this);
mButtonLogin.setReadPermissions("user_friends");
mButtonLogin.setReadPermissions("public_profile");
mButtonLogin.setReadPermissions("email");
mButtonLogin.setReadPermissions("user_birthday");
// Register a callback method when Login Button is Clicked.
mButtonLogin.registerCallback(mCallbackManager, mFacebookCallback);
}
Run Code Online (Sandbox Code Playgroud)
这是我的回调方法.
private FacebookCallback<LoginResult> mFacebookCallback = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d("Shreks Fragment", "onSuccess");
Profile profile = Profile.getCurrentProfile();
Log.d("Shreks …
Run Code Online (Sandbox Code Playgroud) 最近,Facebook发布了SDK 4,提供了新的和酷炫的更新.我试图切换到SDK4以使用新功能,但是,我正在努力使用Facebook的登录功能.
到目前为止,为了以编程方式注销Facebook,我使用了:
Session session = Session.getActiveSession();
session.closeAndClearTokenInformation();
Run Code Online (Sandbox Code Playgroud)
但SDK4似乎不再支持Session了,在官方文档中,他们提到:
有两种方法可以在Android上实现Facebook登录:
LoginButton类 - 它提供了一个可以添加到UI的按钮.它遵循当前的访问令牌,可以记录和退出人员.
好吧,除了使用LoginButton之外,似乎没有办法以编程方式注销Facebook.任何人都有任何想法,请在这里分享.
我刚刚更新了facebook sdk v4.0
并根据使用自定义登录UI的教程
-(IBAction)facebookLoginClick:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
} else if (result.isCancelled) {
// Handle cancellations
} else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
}
}
}];
}
Run Code Online (Sandbox Code Playgroud)
但结果总是为零,错误代码是304,我错过了什么?
我一直在
"Error Domain = com.facebook.sdk.login Code = 308"无法完成操作.(com.facebook.sdk.login错误308.)""
试图从我的设备登录Facebook.
我的代码可以在模拟器上运行,但不能在实际设备上运行.有没有人遇到过这个错误代码?我很乐意根据要求分享代码.
我已经尝试了几个我能找到的答案,但没有一个能与最新的Facebook Android SDK 4.0一起使用.
如何使用最新的SDK更改布局高度?
android facebook android-xml facebook-login facebook-sdk-4.0
有没有办法在不使用Gradle或Maven的情况下将新的Facebook SDK for Android导入Eclipse(类似于过去的方式)?我一直在看一些页面,但我找不到方法.
谢谢
我正在遵循这个教程,但到目前为止我无法使它工作,虽然这是从一年前左右...
我正在使用androidStudo 1.2.2和FacebookSDK 4.
我想使用自定义按钮简单登录facebook,如下图所示:
现在,在本教程的示例中,我遇到了Session
变量问题,它说它无法解决它getActivity()
有没有人在FacebookSDK4.0上试过这个?
这是正确的方法还是有更新的东西?
提前致谢!
TL; TR:如何使用facebook SDK 4.4获取在我的应用程序上登录的用户的电子邮件和名称
到目前为止,我已经设法登录工作,现在我可以从应用程序的任何位置获取当前访问令牌.
我如何配置登录视图控制器和Facebook登录按钮:
class LoginViewController: UIViewController, FBSDKLoginButtonDelegate {
@IBOutlet weak var loginButton: FBSDKLoginButton!
override func viewDidLoad() {
super.viewDidLoad()
if(FBSDKAccessToken.currentAccessToken() == nil)
{
print("not logged in")
}
else{
print("logged in already")
}
loginButton.readPermissions = ["public_profile","email"]
loginButton.delegate = self
}
//MARK -FB login
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
//logged in
if(error == nil)
{
print("login complete")
print(result.grantedPermissions)
}
else{
print(error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
//logout
print("logout")
}
Run Code Online (Sandbox Code Playgroud)
现在在我的主视图中,我可以获得访问令牌,如下所示:
let accessToken = FBSDKAccessToken.currentAccessToken()
if(accessToken …
Run Code Online (Sandbox Code Playgroud) 得到这个错误
framework not found Bolts for architecture x86_64
Run Code Online (Sandbox Code Playgroud)
一步一步跟随Facebook的指南,但我唯一可以想到链接发生错误的地方是在框架搜索路径的构建设置中.我目前在应用程序中尝试的只是在按钮中添加Facebook登录,只是在视觉上确保它可视化加载.没有添加方法功能,但我甚至无法在当前状态下构建项目.
我想通过Facebook登录用户.在以前版本的swift 1.2中,一切都运行良好,但迁移后我似乎无法通过我的FB帐户登录,我仍然收到错误说:
-canOpenURL:URL失败:"fbauth:// authorize /?client_id = ... error:"此应用程序不允许查询方案fbauth"
你能帮帮我吗?
facebook-sdk-4.0 ×10
facebook ×6
android ×5
ios ×3
swift ×2
android-xml ×1
objective-c ×1
swift2 ×1