我用过的代码
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {
// Close the session and remove the access token from the cache
// The session state handler (in the app delegate) will be called automatically
[FBSession.activeSession closeAndClearTokenInformation];
// If the session state is not any of the two "open" states when the button is clicked
} else {
// Open a session showing the user the login UI
// You must ALWAYS ask for basic_info permissions when opening a session …Run Code Online (Sandbox Code Playgroud) 如何在用户会话打开时获取用户名.我尝试了来自Facebook sdk示例的会话登录示例.如果有人知道解决方案,请帮助我.提前致谢.
- (IBAction)buttonClickHandler:(id)sender {
// get the app delegate so that we can access the session property
SLAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {
// if a user logs out explicitly, we delete any cached token information, and next
// time they run the applicaiton they will be presented with log in UX again; most
// users will simply close the app or switch away, …Run Code Online (Sandbox Code Playgroud) 我使用了Amazon Sample Code中的代码片段.以下代码将数据上传到amazon S3存储桶,但我需要上传文件的URL.我正朝着正确的方向前进吗?或者有人能指出我正在犯的错误
任何形式的帮助将不胜感激.
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = S3BucketName;
uploadRequest.key = S3UploadKeyName;
uploadRequest.body = self.uploadFileURL;
//uploadRequest.contentLength = [NSNumber numberWithUnsignedLongLong:fileSize];
[[transferManager upload:uploadRequest] continueWithBlock:^id(BFTask *task) {
// Do something with the response
AWSS3TransferManagerUploadOutput *uploadOutPut = task.result;
NSLog(@"bftask:%@",uploadOutPut); // Upload out put gives me the following response
return nil;
}];
Run Code Online (Sandbox Code Playgroud)
bfTask响应:
bftask:<AWSS3TransferManagerUploadOutput: 0x1706606c0> {
ETag = "\"0aefedfa36b687a74025b1ad50f3101f\"";
serverSideEncryption = 0;
}
Run Code Online (Sandbox Code Playgroud)