iphone Social framework, make text read only - iphone

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.

Related

SLComposeViewController "Facebook not available"

I'm using the code snippet which was posted on my previous question, Simple way to add Facebook/Twitter share to app?
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[slComposeViewController setInitialText:#"Your text"];
[slComposeViewController addImage:[UIImage imageNamed:#"NameOfImage"]];
[self presentViewController:slComposeViewController animated:YES completion:nil];
} else {
//Show alert or in some way handle the fact that the device does not support this //feature
NSLog(#"Facebook not available");
}
But when I run it on the device and in the simulator all I'm getting is "Facebook not available", what could I be doing wrong?
I've looked at the available tutorials, and I've included the libraries that are required, so I'm not sure what else I'm doing wrong.
In Settings.app/Facebook, you need to set up an account.
SLComposeViewController only allows you to posts on FaceBook if you have an account. That's normal behavior, that's how FaceBook works: No account, nothing to do there.
Since iOS6, you can enter your account in iOS allowing apps to use this account with some of the iOS framework without importing the Facebook SDK. Of course, you have little options with the Social.framework, and if you want to do more, like timelines, etc. you'll have to use the FaceBook SDK.

Twitter and facebook integration in cocos2d

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/

How to use the Facebook API, and how can I post a link with status on the users wall via my app?

I'm trying to post a link + status through my app, using this "popup" facebook window where the user is asked to log in, then asked to allow my app to his profile. Then I want him to be able to write a status, with a link I specify attached. This facebook popup would be triggered by a button, not at start of my app (in the documentation I found that they want me to implement it in the appDidFinish launching method...) But I don't want that, I want it like the popup facebook window is only triggered per button tap.
I'm trying to figure this out for a few days now, but finding that all tutorials are out-dated and the Facebook Developer documentation is very weak- atleast for for me. I already downloaded the Facebook-iOS-SDK with the API and JSON included from GitHub. I already did a few attempts, but the furthest I got is that the user was asked to log in, but not through my app, instead Safari opened and the log in field were there, not in my app.
Could someone please post some code, a basic tutorial I might find helpful, or point me to a good online tutorial? I already tried to post to iPhone Dev SDK forums, where other people also asked for this, but never got any help. So could someone out here please put together something that would help out all the newbies?
I want my login screen look like this, and the rest should be in a popup too:
http://www.facebook.com/photo.php?pid=439332&l=c04b210914&id=100001688115647
Thanks a lot in advance!
There is already a sample code in facebook-ios sdk you can see that there are already the code available for some things. Here is a code snippet from the older facebook API but this should work with the newer graph api too
- (void)setStatus:(id)target {
NSString *statusString = #"Testing iPhone Connect SDK";
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
statusString, #"status",
#"true", #"status_includes_verb",
nil];
[[FBRequest requestWithDelegate:self] call:#"facebook.users.setStatus" params:params];
}
WHat you can do is create a controller to handle all the facebook requests like a singleton class and on tap of button do something like this
- (IBAction)showFBLoginDialog:(id)sender {
if(LoggedInFacebook == NO) {
FBLoginDialog *dlg = [[[FBLoginDialog alloc] initWithSession:faceBookController._session] autorelease];
[dlg show];
}
else {
[faceBookController logoutUser];
}
}
If you need further help search on google and stackoverflow you will find a bunch of.

How will this code publish an image to a wall using Facebook Connect?

I would like to know what this code does exactly.
- (void)dialogDidSucceed:(FBDialog*)dialog {
//[self doSomethingExciting];
FBStreamDialog *dialog2 = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self;
dialog2.userMessagePrompt = #"Example prompt";
dialog2.attachment = #"{\"name\":\"Facebook iPhone SDK\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\","
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
// replace this with a friend's UID
// dialog.targetId = #"999999";
[dialog2 show];
}
When I run it it asks me if I want to publish on my and my friends walls, but Im not sure how this will look on the walls. Also does it publish to the users walls and then show up in their friends incoming stream, like "most recent" or does it actually post on every friends wall?
Thanks
Yes. You are posting an image to their stream.
Attachment is an escaped sequence of JSON that Facebook will pick up on and attach an image (and it looks like a link as well).
What the user will see is the image/link preconfigured as a wall post, and they will have a text box to enter their own text referred so as User Message Prompt.
Whether or not it shows up on friends streams depends on their settings, but ultimately, this is a news stream post, and thus has the potential to appear on their home page.
An other answer already explained what the code does.
This is just a tip:
Create three fake FaceBook accounts, and connect them together.
Then use them to do your testings. So you will know exactly what happens, and do all the tests you need during development without loosing all your friends.

Submitting a link via iPhone -> Facebook Connect

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.