How to share a photos with facebook and twitter? - iphone

I have created a photo gallery application using Three20 framework. It works fine with previous, next and play button in toolbar. But i want include a button for sharing the photos with facebook and twitter.
How to make this?
Thanks in advance.....

For a single point of sharing, I think ShareKit is a great utility. You can easily extend the sharing feature to more than just Facebook and Twitter.

You need to understand the Following.
1-Facebook ApI
2-Twitter ApI

I downloaded the Facebook iOS SDK from github and made a custom view controller based on their sample. To post a photo, I used this code:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
image, #"picture",
nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
where the facebook object is an instance of FacebookService provided in the Facebook SDK and image is a UIImage. However it's a lot more complicated than this because first you have to go to the Facebook developers site and register your app to get an App ID and Access Token, then in your app will you have to have the user autheticate your app with Facebook and handle errors, etc. You can figure it all out from their sample code in the SDK.
I haven't tried Twitter yet.

BMSocialShare should get you going.
https://github.com/blockhaus/BMSocialShare

You need to use IOS sdk from facebook here the link: Facebook for iOS SDK

Related

Facebook API Post Message On Friends Wall

I want to ask how to implement text view in Facebook API. I want to post message on friends wall and also how to get friends list and personal details from Facebook.
You have to use the IOS Facebook API. They created a quite detailed Introduction page.
Have a look here:
https://developers.facebook.com/docs/mobile/ios/build/
This image shows the whole process from authorization till publishing something on the news feed. (Also copied from the Facebook Developer tutorial)
Describing the process to get the friend list:
Facebook Api to check in users in an iOS app
Due to many of errors and many of negative comment about Open Graph API in facebook ios 6.
facebook remove the " Post to friends wall via the API ". You can only use the fbconnect of ios 5.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"100004925467891", #"to",
#"http://pri.com/pit.png", #"picture",
#"http://pr.com", #"link",
#"Data", #"caption",
#"data",#"description",
#"Birthday Reminder",#"name",nil];
[[delegate facebook] dialog:#"feed" andParams:params andDelegate:self];
But if u Post to own wall Open Graph API is still working.

Facebook publish_actions to timeline for iOS

After searching Facebook developer documentation / bugs, and questions on stackoverflow.com, it's not clear if Facebook now supports publish_actions to timeline via it's iOS SDK. There are some questions here on this site that relates to publish_actions permission on mobile, but they don't provide any solution.
Has Facebook rolled out publish_actions for mobile for all third party apps or is it still restricted to devs?
Does Facebook allows publishing actions to timeline via it's publish_actions permission via iOS SDK?
Are there any examples, sample code, or tutorials that explain how to achieve it on iOS?
I'd appreciate any pointers.
Yes. Publishing actions works from within iOS just like it works on the Desktop Web, Mobile Web and from within Android.
The method of requesting the publish_actions permission is the same is uses to request any other permission.
The method of publishing actions is the same Graph API call as you make from any platform:
POST https://graph.facebook.com/me/APP_NAMESPACE:ACTION_NAME?OBJECT_NAME=OBJECT_URL&access_token=TOKEN
for example
POST https://graph.facebook.com/me/myapp:cook?recipe=http://exmaple.com/recipe&access_token=TOKEN
In Objective C you might have something like
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[delegate facebook] requestWithGraphPath:#"me/myapp:cook" andParams:#"http://exmaple.com/recipe" forKey:#"recipe"] andHttpMethod:#"POST" andDelegate:self];
I cannot make this work. I have already got my action released by Facebook so sample had been sent from CURL, but from IOS I always get back domain error 1000.
Here is my code:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"http://itunes.apple.com/us/app/ginos-challenge/id509946175",#"og.url",
#"Played on Gino's challenge",#"og:title",
#"http://media.appspy.com/thumbs/images/icons/i509946175_jpg_180x180_q85.jpg",#"og:image",
#"This is my first post",#"og:description",
#"1000", #"game_point",
nil];
// Publish.
// This is the most important method that you call. It does the actual job, the message posting.
[facebook requestWithGraphPath:#"me/[action domain]:[action name]" andParams:params andHttpMethod:#"POST" andDelegate:self];
No, publish_action will not support for posting in timeline. You should add a new tag like fb:explicitly_shared. Set this as BOOL value. If you set true, it will show in the user's timeline, else it will not.

Is it possible to post a message on the wall without a dialogue in iphone app using fbconnect?

I'm using facebook connect for my iphone application. I need to be able to post messages on the wall WITHOUT USING PROMPTING DIALOGUES. All i wanna do is enter text into a textfield and then post the text on the wall by clicking a button. Is it possible to implement this?
This is explained in the tutorial here.
https://developers.facebook.com/docs/mobile/ios/build/#socialchannels
If you DON"T want to use dialogs then you need this.
http://developers.facebook.com/docs/reference/iossdk/request/
http://developers.facebook.com/docs/reference/rest/#publishing-methods
Also see this answer: iOS Development: How can I get a Facebook wall post to show in the friend's news feed?
I'm assuming that you have successfully authenticated the facebook and you have a valid object of facebook.
NSString *message = [yourTextField text];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, #"message",nil];
[facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];

Facebook URL scheme to post a new message from iPhone

I am developing an iPhone application, and want it to be able to post a message to Facebook, by using the Facebook app.
Is there a custom URL to do this?
I've found this page that has a list of Facebook commands, but it doesn't say how to post a new message...
The URL to post a new message to the wall is
fb://publish/?text=some text to post
This works with Facebook app 4.1... I don't know if it works with older versions.
This answer might help you... Especially this : fb://messaging/compose
If you are talking about using a feed post then you have to do this:
[facebook dialog:#"feed" andDelegate:self];
See here for more info
Also if your making this a mobile web app then you could try this:
http://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&display=touch
More info on web app
You could also just use Sharekit, that gives your users the option what to share. Otherwise, you'll have to use the FBDialog from the facebook-ios-sdk or a matching webview using the URL given by the other posters
The method you mention, directly calling the facebook app, a) requires the app to be installed (usually not the case on iPads, for example) and b) is not officially supported by facebook - the two other ways are.

like/comment on news feed programmatically through Facebook iOS Sdk iphone

I have integrated Facebook IOS SDK to my application and able to post news feed to user's wall programmatically in facebook. Now there is other requirement like in facebook we have options under each news feed of like/comment. I searched a lot for this but was not able to find anything related to this.
I am able to read the news feed from the user's wall and I have it in JSON format. I don't know the further implementation path for the same.
How can we achieve this functionality through iOS sdk?
No worries. With Legacy Rest API of facebook, I figured out how to Comment particular news feed.
//How to Like particular News FEED.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Your Comment Text.", #"text",#"NEWs_FEED_ID", #"object_id",nil];
[_facebook requestWithMethodName:#"comments.add" andParams:params andHttpMethod:#"POST" andDelegate:self];
//How to Like particular News FEED.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"NEWs_FEED_ID", #"post_id",nil];
[_facebook requestWithMethodName:#"stream.addLike"