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.
Related
I'm working on making a client for my REST service on the iPhone. I'm a little lost as to how I go about making the GET and POST requests. I make the url from a NSString, convert it to an NSURL and create the NSURLRequest based off of the url. After that I'm pretty lost. Also, sometimes I care about the response, other times I don't. For example, when making a request for a new id, I care about the response because it's the id I'll use to upload my file later, but when I upload the file I don't care because the server doesn't send a response.
Does anyone have some (hopefully)simple sample code that they could point me to / share?
What I have so far:
-(NSString *) makeGetRequest:(NSString *)url :(Boolean)careAboutResult
{
NSString *results = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSError *reqError;
NSURLResponse *response = nil;
if(careAboutResult == YES)
{
//get the result
}
return results;
}
In the code I'm testing with, the URL is
http://192.168.0.108:8081/TestUploadService/RestfulUpload.svc/id/test123_DOT_png
and I'm saying I do care about the result.
Any help would be greatly appreciated.
#nick its good you have created a NSURLRequest now you just need to create a connection to send this request and receive response, this request is GET request.
To make POST request you will need to use NSMutableURLRequest and set its method name and body content. Here in documentation you will find how you can do this.
I want to integrate Twitter in my iPhone App for getting some tweets of a particular twitter account. Please suggest me the best idea to do that ?
NOTE:
1) I just want to show the tweets from a particular account. Any short
method will be help full rather than full twitter integration
2) For now I am using RSS to get the tweets but somewhere I've heard
that RSS twitter feeds are very unreliable and they are going to stop
support for RSS soon.
Regards !!
If you don't want to use a full implementation, you just need to perform a query to the statuses of the specific user
For example, to get the last 20 tweet from charliesheen with ASIHTTPRequest
NSURL *url = [NSURL URLWithString:#"http://twitter.com/statuses/user_timeline/charliesheen.xml"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
- (void)requestFinished:(ASIHTTPRequest *)request {
// this is called if the request is successful
}
- (void)requestFailed:(ASIHTTPRequest *)request {
// this is called if the request fails
}
If don't want to use xml, just change it to json
http://twitter.com/statuses/user_timeline/charliesheen.json
https://github.com/jaanus/PlainOAuth/tree/27a8631a5e32c36ea40d532c8343fafe7cc5e95c
And download the source project..
This links provide you last five tweets..
Got the answer.
- I added MGTwitterEngine into my project.
Here is the code :[MyViewController's -(void)viewDidLoad]-
MGTwitterEngine *twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine getUserTimelineFor:username sinceID:0 startingAtPage:0 count:10];
If you guys need some more clarification feel free to ask. I'll try to help you out as much as I can.
Regards!!
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
I'd like to know if it was possible, if a user wishes to subscribe to updates of my applications, take a form that is automatically subscribed to this newsletter at this address http://www.gseo.it/lists/?p=subscribe&id=2 (this is my mailing list with double opt in) but I'd like to know that a user can subscibe this newsletter directly from my iphone app.
Thanks
You could do an HTTP POST to that form using ASIFormDataRequest.
This isn't working code, but it might look something like:
NSURL *url = [NSURL URLWithString:#"http://www.gseo.it/lists/?p=subscribe&id=2"];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:#"someone#example.com" forKey:#"email"];
[request startSynchronous];
You can get the library here.
Yes of course you can, open up a UIWebview with the the url provided. Don't forget that this may look not good in the iphone browser so providing a custom html code depending on the user agent may improve things.
I want to upload an image to my twitter profile using objective-c. I saw in the twitter API that I need to send a HTML post to http://twitter.com/account/update_profile_image.format and send the picture as a parameter. I am done with the authentication. I am stuck with the uploading. Maybe somebody can help me with sending the picture as a parameter?
You should be using NSURLRequests and NSURLConnection to perform the API requests. If this is true, all you need to do is create an NSMutableURLRequest, set it's URL to the Twitter image upload API URL, set the method to POST.
Then you'll need to create an NSData object to represent your image, which you can do using
NSData *myImageData = [[NSData alloc] initWithData:[myImage CGImage]];
I don't know what the parameter name is for Twitter's upload API, so for arguments sake, lets call it "image". The next thing you need to do is set the image data as the request's body for the "image" parameter, like this
NSString *bodyString = [NSString stringWithFormat:#"image=%#", [[[NSString alloc] initWithData:myImageData encoding:NSStringUTF8Encoding] autorelease]];
[myRequest setBody:bodyString];
Then you can just start your NSURLConnection with the request and it should upload.
If you’ve managed to get started, then this post on CocoaDev should help you set the uploading up. There’s a sample linked at the top too.
I recommend using ASIHTTPRequest
What is ASIHTTPRequest?
ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications.
It is suitable performing basic HTTP requests and interacting with REST-based services (GET / POST / PUT / DELETE). The included ASIFormDataRequest subclass makes it easy to submit POST data and files using multipart/form-data.
See this blog post for an example
Somthing like this
// See http://groups.google.com/group/twitter-development-talk/browse_thread/thread/df7102654c3077be/163abfbdcd24b8bf
NSString *postUrl = #"http://api.twitter.com/1/account/update_profile_image.json";
ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:[NSURL
URLWithString:postUrl]];
[req addRequestHeader:#"Authorization" value:[oAuth oAuthHeaderForMethod:#"POST"
andUrl:postUrl andParams:nil]];
[req setData:UIImageJPEGRepresentation(imageView.image, 0.8)
withFileName:#"myProfileImage.jpg"
andContentType:#"image/jpeg" forKey:#"image"];
[req startSynchronous];
NSLog(#"Got HTTP status code from Twitter after posting profile image: %d", [req
responseStatusCode]);
NSLog(#"Response string: %#", [req responseString]);
[req release];