I'm wanting to integrate Twitter and Facebook into a game using Cocos2D. I just want simple stuff like tweeting "I scored xxx", posting similar message to Facebook page, etc. I've seen numerous libraries offering to make my life easier - ShareKit, AddThis, etc - but I've also read things from people saying they are not that easy, not supported, and so on.
I could just go and get the facebook and twitter SDKs and integrate them in, but I was wondering if anyone had any recommendation for something that I've missed. I need to support iOS4 and 5 so I the library should use the built-in twitter features in iOS5 if present I guess.
Any suggestions or comments on this - perhaps I've just missed something really obvious?
You can share on Facebook by simply inserting the following line of codes.
For twitter I think there isn't exists such an easy way.
NSString *urlString = #"any url";
NSString *title = #"My score is 999";
NSString *shareUrlString = [NSString stringWithFormat:#"http://www.facebook.com/sharer.php?u=%#&t=%#", urlString , title];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
[[UIApplication sharedApplication] openURL:url];
[url release];
You can share on twitter using following code
twt = [[TWTweetComposeViewController alloc] init];
[twt setInitialText:#"Scorred 1000"];
[twt addURL:[NSURL URLWithString:#"url"]];
twt.completionHandler = ^(TWTweetComposeViewControllerResult result) {
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
[twt dismissModalViewControllerAnimated:TRUE];
break;
case TWTweetComposeViewControllerResultDone:
//[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popViewControllerAnimated:TRUE];
break;
default:
break;
}
[twt dismissModalViewControllerAnimated:TRUE];
};
1) For Facebook,Ofcourse you can use facebook SDK and configure it https://github.com/facebook/facebook-ios-sdk . But You may get lots of questions in that. Better read documentation given in facebook website and do it. Feel free to ask any doubt in that.
2)For Twitter, you can use twitter framework which is inbuilt in ios5. Its pretty easy. Try to use tweet sheet in that. It will give a good experience and consistency to the users of ios5.
But You also have to integrate MGTwitterEngine( https://github.com/mattgemmell/MGTwitterEngine ) to give support for ios4 and and its prior versions. Its little difficult.
Hope You got it.
I made some tutorials for a facebook and a twitter helper Class I hope it helps... http://ludosimagos.tumblr.com/
Related
Here is my code:
SLComposeViewController*fvc = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fvc setInitialText:string];
[fvc addImage:[UIImage imageNamed:#"email.png"]];
[fvc setCompletionHandler:^(SLComposeViewControllerResult result) {
How to make facebook post title and text read only ?
I don't think that can be done with the standard framework. (The idea being that posting to Facebook is left as a user activity, not something you can force on them.)
You could, of course, go lower-level and talk to the Facebook API directly but that would be a lot more work. You'll probably find that people don't change the suggested text very much anyway.
I'm upgrading from old sharekit to latest Sharekit2.0.
Ultimately I need to reach this on Facebookshare: https://s3-ap-southeast-1.amazonaws.com/eight29/demo.png
In old sharekit, I can do that by dialog.attachment (FBStreamDialog) as shown as below. However, in latest version, this function is missing.
BStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = #"Post Item to Facebook";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"example\",\"href\":\"http://apps.facebook.com/example/?%d\",\
How can make it?
Thanks!
Liang
FBStreamDialog is not technically a part of ShareKit, but it belongs to Facebook-ios-sdk, which happens to be used in ShareKit.
FBStreamDialog no longer exists in FB's sdk, and other FBDialog family classes are deprecated. I suggest you to use their graph api, check "publishing" section for all possible parameters. Hopefully some will suit your purpose.
As for implementation, check SHKFacebook's - (void)doSend method. You can then subclass SHKFacebook and implement your own.
i Successfully bypass the Twite dialog and post directly to Twitter In ShareKit using following Code
SHKTwitter *twitter = [SHKTwitter new];
[twitter authorize];
SHKItem *item = [SHKItem new];
[item setCustomValue:#"i am tweeting" forKey:#"status"];
twitter.item = item;
[twitter send];
item.shareType = SHKShareTypeText;
item.text = #"hi";
But now also want to apply it to Facebook. plz help me
i use above code from here
Thanks In Advance
FBGraph is much better way to use facebook API in your app.
download the FBGraph Api documents folder then add it to in your folder.
and read the instruction on facebook developer site http://developers.facebook.com/docs/reference/api/.
this is the sample code - sample code
and let me know if you have any query about it.
No it's possible to imitate the Share dialog directly.
You can use the /ID/feed connection but the user status update will appear as "via your app".
I'm building an app that allowed me to post to a user's wall on facebook. This functionality was working fine up until recently, when for some reason, if I try to post to the wall on facebook, I am now getting the error:
"The post's action links must be valid url's. You can see this because you are one of the developers of the app."
Does anyone know why this is happening? I did not change the code at all in my app, and after searching the web, found others are also having the same problem when trying to post to their facebook wall, but without a solution. Does anyone know what is wrong here, and how to fix it?
How old is the code that you are working with? And, are you using OAth 2.0? If you're not you should, because I believe OAuth 1.0 has been deprecated by Facebook and is only supported for "legacy" applications.
I found the solution to my problem. The relevant code that was causing the problem is:
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"Check out this great restaurant!\",\"href\":\"/\",\"caption\":\"%#\",\"description\":\"%# \r %#, %# %#\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.muslimgreenpages.ca/images/gethalal/GetHalal_IC_B_03.png\",\"href\":\"http://www.gethalalapp.com/\"}]}",
restaurantObj.name, restaurantObj.address, restaurantObj.city, restaurantObj.provinceState, restaurantObj.phoneNumber];
dialog.actionLinks = #"[{\"text\":\"Download GetHalal!\",\"href\":\"http://www.gethalalapp.com/\"}]";
[dialog show];
_posting = NO;
[_session logout];
}
In my dialog.attachment, I did not provide a value for the href parameter, so I simply removed it, and everything worked! Thanks very much mdominick for trying to help.
Take care.
I'm trying to post links through the iPhone facebook connect without using the feed control. I want to simulate how the publish a story works on facebooks website, where I pass a link, and it returns back an image, story title, and a link. Right now I only know how to use the feed control, but I'm thinking there has to be a way to use possibly stream.Publish or showDialog, just not really sure which..
Anyone have any experience with this?
Use the facebook demo app.
in the SessionViewController, add this to get extended permission:
- (void)askPermission:(id)target {
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"publish_stream";
[dialog show];
}
Then you need a method to publish the stream. They don't say exactly what data to send. But whateer it is you package it in a dictionary. Since it is a URL, a good guess would be an NSString. You can get more from the API page
I found 5 that might work:
Feed.publishActionOfUser
Feed.publishStoryToUser
Feed.publishTemplatizedAction
Feed.publishUserAction
Also there is:
Links.post
But you'll have to figure it out, depending on what you want to do. You also need to kow the key. I picked url
- (IBAction)sendURL:(id)target{
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:urlString forKey:#"url"];
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:#"Links.post" params:args];
}
I've left some args out, but you get the idea. I;m not sure exactly what one you want, so you'll have to research the method calls.
Hope this helps.