ShareKit programmatically click "publish" - iphone

EDIT: It should be noted that I stated in my original question that I was able to get this working for Twitter (I used the referenced question/answer to get that working) . . . I just needed the answer for how to do it with Facebook. I haven't found an equivalent way to do this with Facebook.
I'm using ShareKit to allow my users to share data from my App with Facebook and Twitter.
I'm having a particular issue with Facebook sharing.
My App is almost completely voice controlled, so upon a voice command I call:
// Create the item to share (in this example, a url)
SHKItem *item = [SHKItem URL:#"http://someurl.com" title:#"some title"];
// Share the item
[SHKFacebook shareItem:item];
This works fine, except the user is presented with a dialog (I think a UIWebView) that allows them to edit the post and either cancel or publish.
Since the App is voice controlled, I want to skip this step, basically programmatically click "publish" for them (call the publish method programmatically). I don't mind if that dialog appears briefly and then goes away (this is how I handle Twitter, I was able to figure out how to do this with Twitter). I'm having no luck finding this publish method though - I assume this is because it is a server side call handled by FBConnect.
Any ideas on a) what code to use to do this, and b) where to put that code)?
Many thanks in advance.
Ben

Related

fbdialog unable to close

I am using the iOS static library project provided by Facebook developers for showing the screen, since there is a session timeout scenario, i have to close the screens when it is 15 mins. when user tries to share the post and if he just leaves it for 15 mins i am not able to close his view instead it just comes like a background after my piece of code which closes all the view (except the fbdialog). the problem is that i don't create fbdialog myself, instead i try that
facebook = [[Facebook alloc] initWithAppId:facebookAppId andDelegate:self] ;
the Facebook class creates the dialog and manages by itself, what has to be done to close the dialog whenever i want from my app to the static library.
In your facebook sdk there must be the methods to close the dialog.
You have to use the delegates it provides in order to send messages to that methods.
Find and implement them in your working class.
It must be something like FBDelegate or FBDialogDelegate, I am not sure, you could share a link to your facebook sdk to see it.
I have worked with several FB sdks and they all ware different.

How can I publish a Watch action for video, that clicking on the object will spawn a permissions dialog?

Taking Viddy, metacafe, and many other, when I click on a Watch action' object (for a video of theirs), I am taken to the following link:
http://www.facebook.com/connect/uiserver.php?app_id=125119214225766&method=permissions.request&redirect_uri=http%3A%2F%2Fwww.viddy.com%2Fvideo%2Fb206f4a5-2256-4a6d-aee0-9a544ea4ef0f&response_type=code&display=page&auth_referral=1&fb_private_mode_enc=ASJTBOcbzLX2w7CG8O_y_nQlB4NgP5FKG1qo0WsqOoeipkrM_MCDSYUTx-7isbjlSiY
Clicking on that link, brings a facebook page (page as in web page, not Facebook Page) requesting permissions for the application (Viddy in this specific link). Only after providing the permissions (and sometimes by canceling as well) will I get redirected to the actual view page in the Viddy website for that video.
When I do the same with my application, the user gets redirected directly to my site, without being prompted for permissions.
I've compared everything I could think of, but I just can't get it to work the same.
What I've tried:
Using my own custom action and object (og:type=myAppNamespace:myObjectType) with a myAppNamespace:myAction action
Using the og:type=video:other and the video.watches action
Adjusting the head prefix code for proper namespace of the Open Graph Protocol
Any mixes between the option (the ones that can work)
If it wasn't clear by now - my app is a video app kinda like Viddy.
Check out the recent Authenticated Referrals feature. I believe it's designed for exactly this purpose.

Adding Logout Button to Share Screen in Facebook Connect for iPhone

I have been playing with Facebook Connect for iPhone, as well as ShareKit. Seems like Facebook Connect will work best for me for now (in case you were going to suggest Sharekit - just beating you to the chase!). But, I am having one difficulty..
I would like to add a 'logout' button to the "Publish this Story" screen (view). I don't want a button on my own view.. this is being called from an action sheet that also has several other sharing options, and I don't want to also have to list a logout option for each service. I have thought about this long and hard, and the best way for me to do it would be to add a button on "Publish this Story", perhaps up in the facebook header. Does anyone know 1) if this CAN be done and 2) if so, how to approach it?
As far as I know, that dialog is served up by Facebook and can't bequeath altered. We had similar needs. We actually decided to offer logout options in Settings instead of from the screen where the sharing options were offered.

iPhone/iOS - How to use "ShareKit" to post only to Facebook or only to Twitter

In my iPhone app, I have two two buttons, labeled "Facebook" and "Twitter".
I want to use the Sharekit framework which makes my sharing very simple. But as shown in the sample code of ShareKit, I can only show many sharing services, which I don't want to include. I want my "Facebook" button to only show the Facebook sharing service, and the same with Twitter. How can I modify ShareKit to work like that?
Update:
Since this answer is still popular, I just wanted to add that with iOS 5 & iOS 6, there is much less need for Sharekit. A lot of popular sharing options are now built into the OS. That being said, this answer is still valid for the sharing services not built into the device, or if your simply more comfortable with Sharekit.
I'll show you how to do it for Facebook, Twitter is exactly the same, just change all the instances of Facebook to Twitter
First, #import "SHKFacebook.h"
then in your button's target method, put the following:
SHKItem *item; //This creates the Sharekit Item
NSURL *url = [NSURL URLWithString:#"http://itunes.apple.com/us/app/...?mt=8"];
The NSURL should be a link to your app on the app store. That way if someone sees a post your app made on Facebook, and they click it, they will be directed to the store so they can download it. Strickly speaking, this is optional, but why wouldn't you try to get new downloads with this extra one line.
Now we need to set up the SHKItem as follows:
item = [SHKItem URL:url title:[NSString stringWithFormat:#"I'm playing someGame on my iPhone! My Highscore is %i, think you can beat it?", highScoreInt]];
Then set up the post like this:
item = [SHKItem URL:url title:#"Share Me!"];
The title parameter is NOT user customizable. Whatever you set here the user will not be able to change. They will have the opportunity to add their own text in addition to whatever you put there.
Finally show the item:
[SHKFacebook shareItem:item];
I hope this helps. As I said, just change the Facebooks in this post to Twitter. Let me know in a comment if you need more help.
Sharekit provides a generic sharing mechanism but also exposes individual services. For instance, if you were to share a URL on twitter, you could write the following code:
#import "ShareKit/Core/SHK.h"
#import "ShareKit/Sharers/Services/Twitter/SHKTwitter.h"
...
SHKItem *item = [SHKItem URL:url title:#"A title"];
[SHKTwitter shareItem:item];
This is all explained in the documentation, but don't fear exploring the header files of the individual services.
I also had the same problem in one of my apps, and tried to force sharekit to do just that.
ShareKit isn't really made for it though, it's meant to be a provide a large range of sharing options - so even after modification, I found that it wasn't a very elegant or efficient solution.
It will save a bit of time, sure - but if you want a good looking, elegant solution I'd suggest integrating twitter and facebook yourself. It takes a bit of time, but you can define the behavior exactly as you want, and theme the interface to suit your app better.

How to post images on facebook wall on a single button click from an iPhone app

I am making an iPhone app where in the user wants that the selected image should be posted on facebook wall on a single button click.
I have Actionsheet button for this.
I want that both authentication of user(loginButtonTapped in tutorial below) and posting images to the wall(rateTapped in tutorial below) be carried out on a single button click.
I am using the example on the link below as my reference for posting images on facebook wall
http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app
I am a newbie.
What should I do?
How can I proceed?
Please Help and Suggest.
Thanks.
You can use the facebook Graph Api for posting images to wall..
Here is the tutorial for this...
http://www.capturetheconversation.com/technology/iphone-facebook-oauth-2-0-and-the-graph-api-a-tutorial-part-2
Before sharing you will always have to get the Facebook credentials first by either opening the Facebook App (which is called SSO / Single Sign On) or, in case the Facebook App is not installed, by opening the WebView or Safari. Posting stuff to Facebook can be pretty tricky therefore I wrote a simple lib, called BMSocialShare. It is also supporting "single click sharing". You can do things like uploading photos to Facebook easily:
BMFacebookPost *post = [[BMFacebookPost alloc] initWithImage:[UIImage imageNamed:#"image.png"]];
[[BMSocialShare sharedInstance] facebookPublish:post];
or also create a normal post:
BMFacebookPost *post = [[BMFacebookPost alloc]
initWithTitle:#"Simple sharing via Facebook, Email and Twitter for iOS!"
descriptionText:#"Posting to Facebook, Twitter and Email made dead simple on iOS. Simply include BMSocialShare as a framework and you are ready to go."
andHref:#"https://github.com/blockhaus/BMSocialShare"];
[post setImageUrl:#"http://www.blockhausmedien.at/images/logo-new.gif"
withHref:#"http://www.blockhaus-media.com"];
[[BMSocialShare sharedInstance] facebookPublish:post];
I wanted to add on my personal experience on using BMSocialShare created by vinzenzweber here, and my reputation only allows me to answer. It saved me a lot of time and from the trouble of reading Facebook's documentation, for something as simple as sharing an image for my photo app.
Just a couple of pointers on the documentation of it which might not be immediately obvious for someone using the library for the first time.
When inserting the snippet into your Info.plist containing the Facebook app id, you need to affix 'fb' in front of the number app id.
Besides adding the BMSocialShare.framework into the Xcode Project, you need to manually drag the BMSocialShare.bundle and the FBDialog.bundle in the resources folder of the BMSocialShare.framework, into the Copy Bundle Resources section under Build Phrases of your application's target