在 Facebook 墙上发布字符串而不显示对话框(iPhone Facebook SDK)

发布于 2024-10-20 10:42:50 字数 465 浏览 4 评论 0原文

我一直在搜索 stackoverflow 和互联网,但没有找到符合我意图的可行解决方案。

我想调用一个以字符串作为参数的方法,然后将其发布到 Facebook 墙上而不显示对话框。当然,只有当有效会话可用时。

我尝试过:

// post message to facebook pinnwall
- (void)postOnWall:(NSString *)message {

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",nil];
    [[FBRequest request] call:@"facebook.stream.publish" params:params];
}

你们能帮我一个工作方法吗?

谢谢和欢呼, 杜诺特

I have been searching stackoverflow and the internet and did no find a working solution for my intention.

I want to call a method with a string as parameter which is then posted to the facebook wall without showing a dialog. Of course only when a valid session is available.

I tried this:

// post message to facebook pinnwall
- (void)postOnWall:(NSString *)message {

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",nil];
    [[FBRequest request] call:@"facebook.stream.publish" params:params];
}

Can you guys help me ou with a working method?

Thanks and cheers,
doonot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

錯遇了你 2024-10-27 10:42:50

正如 Aby 所说,您必须充分发挥 FB 用户的 Graph API 潜力。

简单代码:

NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];

NSString *wallPost = @"the super wall post";
NSString *linkURL  = @"http://www.supersite.com";
NSString *imgURL   = @"http://www.supersite.com/image.jpg";

[fbArguments setObject:wallPost forKey:@"message"];
[fbArguments setObject:linkURL  forKey:@"link"];
[fbArguments setObject:imgURL   forKey:@"picture"];

[facebook requestWithGraphPath:@"me/feed" 
                    andParams:fbArguments
                andHttpMethod:@"POST"
                  andDelegate:self];

as Aby said, you have to look at the Graph API to user FB at its full potential.

simple code:

NSMutableDictionary *fbArguments = [[NSMutableDictionary alloc] init];

NSString *wallPost = @"the super wall post";
NSString *linkURL  = @"http://www.supersite.com";
NSString *imgURL   = @"http://www.supersite.com/image.jpg";

[fbArguments setObject:wallPost forKey:@"message"];
[fbArguments setObject:linkURL  forKey:@"link"];
[fbArguments setObject:imgURL   forKey:@"picture"];

[facebook requestWithGraphPath:@"me/feed" 
                    andParams:fbArguments
                andHttpMethod:@"POST"
                  andDelegate:self];
jJeQQOZ5 2024-10-27 10:42:50

您是否尝试过使用 Graph API..
如果您希望应用程序在墙上打印而不需要像对话框这样的用户交互,您可以使用图形 API。
http://developers.facebook.com/docs/reference/api/post/

Have you tried using Graph API..
If you like your application to print on the wall without the user interaction like Dialog box you can use the Graph API..
http://developers.facebook.com/docs/reference/api/post/

白芷 2024-10-27 10:42:50

发布到 Facebook Wall 你应该通过 JSON

检查这个代表

- (void)postToWall {

    FBStreamDialog *dialog =[[[FBStreamDialog alloc]init ]autorelease];

    dialog.userMessagePrompt = @"Whats on your Mind about this Articles...";
    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"The Black Sheep: %@ Specials for %@, %@ \",\"href\":\"http://%@/\",\"caption\":\" %@ \",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"http://www.raywenderlich.com/\"}]}",
                         [[BarSplArr objectAtIndex:0]objectForKey:@"barname"],day,date,[[BarSplArr objectAtIndex:0]objectForKey:@"barwebsite"],[[BarSplArr objectAtIndex:0]objectForKey:@"drinkspecials"],[[BarSplArr objectAtIndex:0]objectForKey:@"barimage"]];
    //dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";
    [dialog show];
}

更好你可以通过这种方式跟进。 http://www.raywenderlich.com /77/how-to-post-on-facebook-with-your-iphone-app

精彩教程

Posted to Facebook Wall u should go through JSON

check out this delgates

- (void)postToWall {

    FBStreamDialog *dialog =[[[FBStreamDialog alloc]init ]autorelease];

    dialog.userMessagePrompt = @"Whats on your Mind about this Articles...";
    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"The Black Sheep: %@ Specials for %@, %@ \",\"href\":\"http://%@/\",\"caption\":\" %@ \",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"http://www.raywenderlich.com/\"}]}",
                         [[BarSplArr objectAtIndex:0]objectForKey:@"barname"],day,date,[[BarSplArr objectAtIndex:0]objectForKey:@"barwebsite"],[[BarSplArr objectAtIndex:0]objectForKey:@"drinkspecials"],[[BarSplArr objectAtIndex:0]objectForKey:@"barimage"]];
    //dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";
    [dialog show];
}

better u can follow up this way. http://www.raywenderlich.com/77/how-to-post-on-facebook-with-your-iphone-app

superb tutorial

倾其所爱 2024-10-27 10:42:50

注意:必须需要“publish_actions”权限,并处理和检查 accessToken &用户是否已登录。

func postMessageOnFaceBookWall() 
   {
        FBSDKGraphRequest(graphPath: "me/feed", parameters: ["message": "Hello my test post"], httpMethod: "POST").start { (connection, result, error) in
            if error == nil{
                //Handle your response here
           }
            else{
               // error
            }
        }
    }

NOTE : must need "publish_actions" permission and also handle and check accessToken & user is logged in or not.

func postMessageOnFaceBookWall() 
   {
        FBSDKGraphRequest(graphPath: "me/feed", parameters: ["message": "Hello my test post"], httpMethod: "POST").start { (connection, result, error) in
            if error == nil{
                //Handle your response here
           }
            else{
               // error
            }
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文