Tid*_*dly 8 iphone facebook facebook-graph-api ios facebook-ios-sdk
我想在iOS应用中使用facebook sdk将一些文本发布到用户墙.
现在发布一个开放的图形故事是唯一的方法吗?
我发现它们是开放的图形故事,它们真的很奇怪,你只能以"用户xa y"的格式发布信息,你可以直接在Facebook上预设x和y,就像用户在比萨饼或用户玩游戏一样.设置每一个也非常费力,因为你必须在外部服务器上为每个创建一个.php对象.
我错过了什么或者有更简单的方法吗?
Tid*_*dly 10
通过浏览facebook教程了解更多.
-(void) postWithText: (NSString*) message
ImageName: (NSString*) image
URL: (NSString*) url
Caption: (NSString*) caption
Name: (NSString*) name
andDescription: (NSString*) description
{
NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
url, @"link",
name, @"name",
caption, @"caption",
description, @"description",
message, @"message",
UIImagePNGRepresentation([UIImage imageNamed: image]), @"picture",
nil];
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
{
// No permissions found in session, ask for it
[FBSession.activeSession requestNewPublishPermissions: [NSArray arrayWithObject:@"publish_actions"]
defaultAudience: FBSessionDefaultAudienceFriends
completionHandler: ^(FBSession *session, NSError *error)
{
if (!error)
{
// If permissions granted and not already posting then publish the story
if (!m_postingInProgress)
{
[self postToWall: params];
}
}
}];
}
else
{
// If permissions present and not already posting then publish the story
if (!m_postingInProgress)
{
[self postToWall: params];
}
}
}
-(void) postToWall: (NSMutableDictionary*) params
{
m_postingInProgress = YES; //for not allowing multiple hits
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Post Failed"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
m_postingInProgress = NO;
}];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10957 次 |
最近记录: |