简体   繁体   English

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

[英]Post string on Facebook wall without showing dialog (iPhone Facebook SDK)

I have been searching stackoverflow and the internet and did no find a working solution for my intention. 我一直在搜索stackoverflow和互联网,并没有为我的意图找到一个有效的解决方案。

I want to call a method with a string as parameter which is then posted to the facebook wall without showing a dialog. 我想调用一个带有字符串作为参数的方法,然后将其发布到Facebook墙上而不显示对话框。 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 谢谢和欢呼,doonot

as Aby said, you have to look at the Graph API to user FB at its full potential. 正如Aby所说,你必须充分发挥用户FB的Graph API。

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];

NOTE : must need "publish_actions" permission and also handle and check accessToken & user is logged in or not. 注意:必须具有“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
            }
        }
    }

Posted to Facebook Wall u should go through JSON 张贴到Facebook Wall你应该通过JSON

check out this delgates 看看这个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 http://www.raywenderlich.com/77/how-to-post-on-facebook-with-your-iphone-app

superb tutorial 精湛的教程

Have you tried using Graph API.. 您是否尝试过使用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/ 如果您希望应用程序在墙上打印而无需用户交互(如对话框),则可以使用Graph API .. http://developers.facebook.com/docs/reference/api/post/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM