I have google'd and searched around for a solution but I can't find much.
I need to send a HTTP POST request from objective-c to my couchdb.
What I need to know is how to add an image to the request in objective-c, and preferably a link to a library/framework which simplifies the while process of sending requests from iOS.
I Have found a couple of frameworks, but one was no longer in development and the other had not been updated in a year.
Anyone have any experience on this?
I've been working on something similar, I use the AFNetworking library to post to a php script
which then puts it into a Mysql database.
It should be much simpler in your case because you can post directly to couchDB
The AFNetworking library has examples that should do just what you need.
https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking
Related
Does anybody have experience at using Sofia-Sip?
I'm trying to answer incoming calls. I managed it to create a session, but no media stream is established...
Does anybody have a simple example about this? I've already looked at the CLI client of sofia-sip and at telepathy-rakia, which were both quite complicated.
I'm not too familiar with media yet. I'd like to answer an incoming call, and get the G.711 payload to further process it.
Any help is appreciated
Found it out on my own, it's written there deep in the specifications of nua library.
You have to send the information about what media you support at latest in the 200 OK response to the calling party.
I can provide source code here if someone is interested. Otherwise I'm not making the effort to clean it for this purpose.
For my project course I'm thinking to develop an application in iPhone. I have some objective-c knowledge but I don't know what kind of API's Apple provide.
I've implemented RESTful web service and I was wondering if there is a way to access features of this RESTful API via iPhone. I mean, what kind of API's area available to send HTTP GET, POST, ... and to process JSON/XML data returned by web service?
Any help is very much appreciated.
All HTTP request methods (POST, GET, PUT, DELETE, etc…) are available with NSURLConnection.
You can parse XML with NSXMLParser and you can parse JSON with JSON-Framework (it's really good).
This tutorial may be helpful: Tutorial: Simple iPhone Rest Client
A great and widely accepted API for HTTP requests/etc is ASIHTTPRequest, here is the link. As far as XML parsing, you might want to take at the Apple provided NSXMLParser (note there could be external APIs for this, but I am unaware of them). Here is its class Reference
I have a general question. Using the NSMutableURLRequest object in the iPhone SDK, can I set the HTTPMethod to POST when retrieving data from a server?
Normally you should either POST some data or GET some data, though issuing a POST and then fetching some data in a single request is perfectly valid.
Just to be clear, it is in fact quite common for a POST to return some data representing some sort of result message in response to the POST. Other uses (like piggy-backing an unrelated GET onto the POST) would be frowned upon.
If you are wanting to be HTTP / web standards compliant, you should use a GET when retrieving data. It will also depend on if the application you are talking to on the server will respond to a POST request for the given resource.
If you're willing to use third party libraries I can highly recommend ASIHTTPRequest:
http://allseeing-i.com/ASIHTTPRequest/
I've used this in library for http posts in a number of iPhone applications and been very happy with it.
Just to clarify: I'm not associated with these guys in any way, just like the library!
been wrestling with this for some time. I am trying to access a REST api on my iphone and came across the ASIHTTP framework that would assist me. So i did something like
//call sites, so we can confirm username and password and site/sites
NSURL *url = [NSURL URLWithString: urlbase];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUsername:#"doronkatz%40xx.com" ];
[request setPassword:#"xxx"];
Where urlbase is a url to a REST site.
Now, a developer has told me there might be an issue or bug with this framework, and its not passing headers correctly. Is there another way of testing or accessing with authentication a network REST location?
I would recommend checking out RestKit: http://restkit.org/ It provides an excellent API for accessing RESTful web services and representing the remote resources as local objects, including persisting them to Core Data. HTTP authentication is supported out of the box.
I'm new to iOS development and I've been battling with some of the big frameworks listed on this page for the past month or so. It has been a nightmare. I'd honestly recommend you just stick to the basics and do it yourself using AFNetworking or Apple's own NSURLConnection.
One of the libraries listed is no longer maintained. Another underwent huge code-breaking API changes recently and now half of the tutorials describing its use no longer work. Others are massively bloated.
It's easier than you'd think. Some resources that helped me:
http://blog.strikeiron.com/bid/63338/Integrate-a-REST-API-into-an-iPhone-App-in-less-than-15-minutes
http://www.slideshare.net/gillygize/connecting-to-a-rest-api-in-ios
The examples on the AFNetworking homepage alone may get you 80% of the way there.
UPDATE: The Mantle Framework (open sourced by Github Inc.) is well-designed and easy to use. It handles object mapping: converting a JSON NSDictionary to your own custom Objective-C model classes. It handles default cases sensibly and it's pretty easy to roll your own value transformers, e.g. from string to NSURL or string to your custom enum.
I have a couple of apps using a framework called Objective Resource which provides a wrapper for accessing remote REST based api's. It is aimed primarily at Ruby on Rails based applications so it's XML/JSON parsing may be tuned to handle some Rails defaults but it is worth looking at. It supports http basic authentication by default.
Just stumbled on this question - you might find LRResty pretty interesting as it uses NSOperation, blocks etc., see: GitHub for source (MIT license). I'm experimenting with it now - it has a sample app too.
I've used ASIHTTP in two apps so far and have had no problems.
Looks like you're doing HTTP Basic Auth with the remote site. Try hitting the same REST URL from a standard browser and pass the params you need down to it. It should prompt you for username/password. If it makes it through, then at least you know the server-side is set up to handle requests. If it doesn't, then you need to have a talk with the dev.
The next thing to try is put a Mac-based network sniffer and see what headers are going back and forth. Any of HTTPScoop, Wireshark, or Charles should work. Run the sniffer as a network proxy then run your app in the simulator and watch what goes across. Try it again with the browser. Once you see the differences, you can use the addRequestHeader method on ASIHTTPRequest to add any specific headers the server expects.
I'm working on an iPhone project that needs to receive data from a PHP script during execution. My first thought was to use sockets/streams on either end to connect the two, but I am having trouble finding information on how to do this from the iPhone side.
Has anyone been down this path that could point me towards some useful resources or offer some advice? The official documentation seems to be geared more towards desktop apps and uses code that doesn't seem to be supported on the iPhone (namely NSHost).
Update: The intended use of this app is to receive log messages from an executing script, so I can't use a simple HTTP request with JSON or XML. Many cases will involve the page being loaded by another client, where the script would relay/push log messages to the iPhone.
Polling is evil. You'll chew through batteries doing that.
You might consider running an HTTP server on the iPhone. Check out this blog post; it has an implementation of an HTTP server in Cocoa as well as example code for using it for two-way communication.
The PHP CURL library (can't link it because the site doesn't trust me yet, just search php.net for it) is a (relatively) simple, easy way to make http requests with a PHP script.
Why don't you just use HTTP? Create an ad-hoc protocol with XML or JSON, use POST for upstream data transmission. I'm a fan of JSON for this sort of thing, personally. The PHP, instead of returning a webpage in HTML for rendering, should just return your data in a JSON format.