Objective-C equivalent of curl request

前端 未结 2 1014
长发绾君心
长发绾君心 2020-12-09 21:36

I\'m trying to manipulate this curl request in Objective-C:

curl -u username:password \"http://www.example.com/myapi/getdata\"

I\'ve implem

2条回答
  •  执笔经年
    2020-12-09 22:21

    This guide seems to do what you're looking for: http://deusty.blogspot.co.uk/2006/11/sending-http-get-and-post-from-cocoa.html

    Just as an FYI, a lot of classes accept initWithData, and NSData has a method dataWithContentsOfURL, if you want to avoid setting up NSURLConnections yourself this could be an easier way of achieving what you're looking for.

提交回复
热议问题