Google Analytics API with Objective c, Part two

by roberto.vega 16. October 2009 15:45

Well it is time for part two. Part one was easy and the second part is easy as well.
Now that we got the authentication token we can get analtyics data.
The data we are getting is the accounts and profiles for analytics:

NSURL *urlAccount = [NSURL URLWithString:@"https://www.google.com/analytics/feeds/accounts/default"];

NSString* param = [NSString stringWithFormat:@"GoogleLogin auth=%@",authString]; 
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:urlAccount];
[req setHTTPMethod:@"GET"];
[req addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[req setValue:param forHTTPHeaderField: @"Authorization"];
[req addValue:@"Authorization" forHTTPHeaderField:param];

NSHTTPURLResponse *res;
NSError *err;
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];

[req release];
return data;

Finally u get a NSData. I personal use libxml2 for parsing the xml data and XPath queries. Check out http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html for more info :)

Tags: , ,

Development

Comments

11/5/2009 2:16:07 AM #

PLR articles

I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

PLR articles United States

11/6/2009 11:54:52 AM #

internet marketing consultant

Howdy, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam comments? If so how do you prevent it, any plugin or anything you can advise? I get so much lately it's driving me mad so any assistance is very

internet marketing consultant United States

12/8/2009 10:48:44 AM #

honda dealers nj

I was looking for crucial information on this subject. The information was important as I am about to launch my own portal. Thanks for providing a missing link in my business.



Regards
Carcol

honda dealers nj United States

12/10/2009 9:38:40 AM #

Algarve Villa Rentals

Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!


Regards
Fu







Algarve Villa Rentals United States

12/25/2009 10:10:21 AM #

OH Payday Loans

Nice post . keep up the good work

OH Payday Loans United States

1/10/2010 12:56:06 PM #

منتدى

Nice!

Thank you

http://www.2fnn.com

منتدى Saudi Arabia

1/27/2010 5:15:43 AM #

دردشة

wetwer

دردشة Brunei Darussalam

1/27/2010 6:02:39 AM #

دردشة

<a title="شات الخليج"href="http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">شات الخليج</a>
<a title="دردشة الخليج"href="http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">دردشة الخليج</a>
<a title="الخليج"href="http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">" rel="nofollow">http://www.alkhaleg.com/">الخليج</a>  

دردشة Austria

1/29/2010 5:58:50 PM #

منتديات

So thanks, it is Very nice and So cute ,
Please keep that Up

منتديات Germany

2/27/2010 8:34:15 AM #

Fatcow Coupon

Should I get a VPS? Right now I am using godaddy but they keep shutting me down due to high server overload. Im getting about 3,000 unique views a day. What brand should I get?

Fatcow Coupon United States

3/3/2010 5:12:07 AM #

wow mobiles

WoW Mobile is awesome! I get free mobile service with t-mobile because I refered 3 people to wow. You can too!

wow mobiles United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Sweden License.


Welcome to the Dropit blog!

Here we, the people that work at Dropit, will write about stuff that interests us. For example web development, especially with .NET and EPiServer - but we'll also talk about other techniques that interest us, marketing on the web, social phenomenons, pop culture, games and software development in general.