How to pass URL with tweet in twitter? - iphone

I want to send text along with URL as tweet to twitter from my iPhone app and i have used XAuth but don't know how to do that.
Please give your suggestions.
Thanks

Its simple there is no separate methods for that.
Just combine the URL with the Text
NSString *tweet = [[NSString alloc] initWithFormat:#"Your Tweet Message http://stackoverflow.com/"];
[engine sendUpdate:tweet];
//engine is your Twitter Object

Related

Is it possible to bypass the share dialog and post directly to Facebook? in share kit

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".

UIMessage "sending direct mail"

I am developing an exam app. After the completion of the exam, if the person presses the done button, the results will be sent directly to the person's email.
I know how to use the MessageUI framework, but i don't want to get any compose view - instead it should go directly to the concern email.
Does anybody know if this is possible?
Thanks in advance.
For example syntax :
NSString *msgToSend = #"This is an Example Message to be send";
NSString *urlStr = [NSString stringWithFormat:#"www.home.com?method=aMethodName&msg=%#",msgToSend]; //here msg is a parameter of your url string
NSLog(#"%#",urlStr);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Hope it gives you an idea...
This is possible but for this you need a webservice which will send the mail.

Facebook iOS Integration

I have recently implemented the Facebook functionality to post an URL as explained in iOS Facebook Development
It's the same as explained.
After I've signed up on Facebook and set my app key, I started the iPhone simulator and authorized as explained on Facebook. After that the Mobile Safari didn't jump back to my app (Because I don't want Facebook to jump back. Later I want to do that calling a webpage by my own). So I just started it again (activated because of iOS 4.2).
After that, I switched to the where I post a default URL.
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *communityURL = #"http%3A%2F%2Fwww.google.com";
[params setObject:communityURL forKey:#"link"];
[facebook dialog:#"feed" andParams:params andDelegate:self];
Normally it should bring up a dialog with this parameters, but it just showed an error:
This page contains the following errors:
error on line 25 at column 35: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.
When I debug into the method which calls the dialog, I got the URL, which will be called.
When executing this URL in a web browser, it works.
Why doesn't it work?
What's wrong?
i didn't figure out what it was, but i came up with an other solution.
I now use ShareKit. It's easy to use and it handles all alone. I try to post some sourcecode snipets asap.
For those, who have the same problem and don't want to use another API, try to do what ever the facebook documentation tells you.
Br
Nic
ok what I did is simply add
NSURL *url = [NSURL URLWithString: #"http://www.google.com"];
SHKItem *item = [SHKItem URL:url title:#"Share Item with Google url ;)"];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showFromTabBar:self.tabBarController.tabBar];
And that's what I do.
If someone needs help, please feel free!!
Br
Nic

How to do string formatting in Objective-C?

I am trying to post text from my iPhone app to my wall on Facebook. Everything works fine, however, my problem is that I am not sure how to format the text. I would like to show the user the name, address, city, state, and phone number of the restaurant they are viewing on the app. Here is my relevant code:
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%# got straight A's!\",\"href\":\"http://www.example.com/\",\"caption\":\"%# must have gotten real lucky this time!\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.abc.png\",\"href\":\"http://www.example.com/\"}]}",
_facebookName, _facebookName];
dialog.actionLinks = #"[{\"text\":\"Download GetHalal!\",\"href\":\"http://www.example.com/\"}]";
[dialog show];
}
I would like to show the user the restaurant information in the dialog.attachment variable, such that the output on the facebook wall looks like this:
restaurant.name
restaurant.address
restaurant.city, restaurant.state
restaurant.phoneNumber
My problem is, the text above appears to be in JSON format. The restaurant object is available in the class, and I'd like to include it in the code above, but I don't know how. Can anyone show me how to do this?
Use a JSON library:
https://stackoverflow.com/questions/286087/best-json-library-to-use-when-developing-an-iphone-application
Also, check the Facebook sdk for iOS:
http://developers.facebook.com/docs/guides/mobile/#ios
The accepted answer in this StackOverflow post has the code you need, with JSONfragment:
How to post a message with attachment in Facebook?
(note that, in this case, the library used is http://code.google.com/p/json-framework/ )

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.