It looks like you're new here. If you want to get involved, click one of these buttons!
#import "writeblog.h"
#import <QuartzCore/QuartzCore.h>
#import "RSSEntry.h"
#import "ASIHTTPRequest.h"
#import "GDataXMLNode.h"
#import "GDataXMLElement-Extras.h"
#import "NSDate+InternetDateTime.h"
#import "NSArray+Extras.h"
#import "WebViewController.h"
#import "UniqueDomainIDBlog.h"
@implementation writeblog
@synthesize posttext;
@synthesize allEntries = _allEntries;
@synthesize feeds = _feeds;
@synthesize queue = _queue,webView;
- (void)refresh {
for (NSString *feed in _feeds) {
NSURL *url = [NSURL URLWithString:feed];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[_queue addOperation:request];
}
}
- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
NSString *status = [rootElement valueForChild:@"status"];
NSLog(@"the status is %@ ",status);
NSUserDefaults *st=[NSUserDefaults standardUserDefaults];
[st setObject:status forKey:@"statusdefault"];
if ([status intValue]==1) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Post Sent Successfully"
message:@""
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
if ([status intValue]==0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Post send failed"
message:@"Please try again"
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
- (void)parseFeed:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
if ([rootElement.name compare:@"rss"] == NSOrderedSame) {
[self parseRss:rootElement entries:entries];
}
else if ([rootElement.name compare:@"response"] == NSOrderedSame) {
[self parseRss:rootElement entries:entries];
}
else {
NSLog(@"Unsupported root element: %@", rootElement.name);
}
}
- (void)requestFinished:(ASIHTTPRequest *)request {
[_queue addOperationWithBlock:^{
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:[request responseData]
options:0 error:&error];
if (doc == nil) {
NSLog(@"Failed to parse %@", request.url);
}
else {
NSMutableArray *entries = [NSMutableArray array];
[self parseFeed:doc.rootElement entries:entries];
}
}];
}
-(IBAction)hidekeyboard{
[posttext resignFirstResponder];
}
-(IBAction)submitpost{
NSString *text=posttext.text;
NSUserDefaults *st2=[NSUserDefaults standardUserDefaults];
NSString *session=[st2 objectForKey:@"session_iddefault"];
self.allEntries = [NSMutableArray array];
self.queue = [[NSOperationQueue alloc] init] ;
NSString *url1=[NSString stringWithFormat:@"http://sme.allomani.com/apps/api.php?action=blog_write&domain_id=1&content=%@&session_id=%@",text,session];
self.feeds = [NSArray arrayWithObjects:url1,
nil];
NSLog(@"session %@ and url is %@",session,url1);
[self refresh];
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
posttext.layer.borderWidth = 5.0f;
posttext.layer.borderColor = [[UIColor grayColor] CGColor];
posttext.layer.cornerRadius = 5;
posttext.clipsToBounds = YES;
controlflowin=1;
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Any help will be greatly appreciated, thank you.