https://github.com/tidev/apshttpclient
APSHTTPClient (TiHTTPClient)
https://github.com/tidev/apshttpclient
Last synced: about 1 year ago
JSON representation
APSHTTPClient (TiHTTPClient)
- Host: GitHub
- URL: https://github.com/tidev/apshttpclient
- Owner: tidev
- License: other
- Created: 2014-04-15T18:15:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T21:41:46.000Z (over 2 years ago)
- Last Synced: 2024-05-01T11:49:16.806Z (about 2 years ago)
- Language: Objective-C
- Homepage:
- Size: 5.2 MB
- Stars: 4
- Watchers: 47
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/appcelerator/APSHTTPClient)
### Requirements
**MobileCoreServices.framework**
### Components
**APSHTTPRequest** - Responsible for the http request
**NSObject\** - Responsible for the APSHTTPRequest callbacks
**APSHTTPPostForm** - Used to build a post form
**APSHTTPResponse** - Holds all the response information from the request
**APSHTTPHelper** - Helper class with some handy functions
### GET Request:
```objc
// in header
#import
-(void)sendRequest
{
APSHTTPRequest *request = [[[APSHTTPRequest alloc] init] autorelease];
[request setDelegate:self];
[request setMethod: @"GET"];
[request setUrl:[NSURL URLWithString: @"http://google.com/"]];
[request send];
}
- (void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
{
NSString* responseString = [response responseString];
}
- (void)request:(APSHTTPRequest *)request onError:(APSHTTPResponse *)response
{
NSString* errorMessage = [[response error] localizedDescription];
}
```
### POST Request:
```objc
// in header
#import
-(void)sendRequest
{
APSHTTPPostForm *form = [[[APSHTTPPostForm alloc] init] autorelease];
[form addFormKey:@"first_name" andValue: @"John"];
[form addFormKey:@"last_name" andValue: @"Smith"];
[form addFormData: UIImageJPEGRepresentation([[self myImageView] image], 0.7)
fileName:@"image.jpeg"
fieldName:@"photo"];
APSHTTPRequest *request = [[[APSHTTPRequest alloc] init] autorelease];
[request setDelegate:self];
[request setMethod: @"POST"];
[request setPostForm:form];
[request setUrl:[NSURL URLWithString: @"http://some_server.com/api/post"]];
[request send];
}
- (void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
{
NSString* response = [response responseString];
}
- (void)request:(APSHTTPRequest *)request onError:(APSHTTPResponse *)response
{
NSString* errorMessage = [[response error] localizedDescription];
}
```