壁に写真を公開する必要がありました。写真は私のiPadアプリで生成されます。
8054 次
2 に答える
24
これは私が見つけた最も簡単な方法です
- (void) postImageToFB:(UIImage*)image
{
NSData* imageData = UIImageJPEGRepresentation(image, 90);
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"This is my drawing!", @"message",
imageData, @"source",
nil];
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
}
友達の壁に投稿したい場合は@"me/photos"
、@"[friendID]/photos"
次に、公開してメソッドを呼び出すための権限を要求します
if ([FBSession.activeSession.permissions indexOfObject:@"publish_stream"] == NSNotFound)
{
// No permissions found in session, ask for it
[FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_stream"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
// If permissions granted, publish the story
if (!error) [self postImageToFB:currentDrawing];
}];
}
// If permissions present, publish the story
else [self postImageToFB:currentDrawing];
「[アプリ名]写真」アルバムが存在しない場合は作成されます
それは私のために働きます!
于 2012-10-20T03:25:41.327 に答える
-1
4.3 からの iOS と iOS 6.0 のような UI の場合、次のようなものが必要だと思います: twitter、facebook、flicr、tumblr 用の IOS 共有フレームワーク
于 2013-01-23T08:13:02.363 に答える