Permalink
Browse files

Committing Adrian's changes.

  • Loading branch information...
1 parent 811821d commit 5a4e5dd90f3544b02a874e1607b43aae85e5848a @synedra synedra committed Sep 1, 2010
Showing with 19 additions and 5 deletions.
  1. +2 −1 Classes/NetflixShopperId.h
  2. +17 −4 Classes/NetflixShopperId.m
@@ -27,5 +27,6 @@
// these functions can be accessed by an ephemeral instance
- (NSString *)getShopperId; // return the id if we have one persisted
- (void)setShopperId:(NSString *)sid; // change the persisted id
-
+- (NSString *)getNetflixId; // return the id if we have one persisted
+- (void)setNetflixId:(NSString *)nid; // change the persisted id
@end
View
@@ -11,6 +11,7 @@
#import "ASINetworkQueue.h"
#define SHOPKEY @"NFLX_SHOPPERID"
+#define NETFLIXKEY @"NFLX_NETFLIXID"
@implementation NetflixShopperId
@@ -19,9 +20,10 @@ @implementation NetflixShopperId
// shopperId is an authentication token found in the Netflix website cookie.
// if a user logs out and back in, their shopperId will change, so check it each time
+// NetflixId is a more recent authentication cookie
- (void) obtainShopperIdWithAsyncRequest {
- //NSLog(@"Loading shopperid from http://www.netflix.com/WiHome");
- NSURL *webUrl = [NSURL URLWithString:@"http://www.netflix.com/WiHome"];
+ //NSLog(@"Loading netflixid and shopperid from https://www.netflix.com/YourAccount");
+ NSURL *webUrl = [NSURL URLWithString:@"https://www.netflix.com/YourAccount"];
[networkQueue cancelAllOperations];
networkQueue = [ASINetworkQueue queue];
[networkQueue retain];
@@ -38,10 +40,11 @@ - (void)idDidLoad:(ASIHTTPRequest *)request {
//NSLog(@"NetflixShopperId async request succeeded");
NSArray *cookies = [request responseCookies];
for(NSHTTPCookie *oneCookie in cookies) {
+ NSLog(@"Cookie %@ = %@", [oneCookie name], [oneCookie value]);
if ([@"NetflixShopperId" isEqualToString:[oneCookie name]]) {
[self setShopperId:[oneCookie value]];
- //NSLog(@"NetflixShopperId from cookie = %@", [oneCookie value]);
- break;
+ } else if ([@"NetflixId" isEqualToString:[oneCookie name]]) {
+ [self setNetflixId:[oneCookie value]];
}
}
}
@@ -66,6 +69,16 @@ - (void)setShopperId:(NSString *)sid
[[NSUserDefaults standardUserDefaults] setObject:sid forKey:SHOPKEY];
}
+- (NSString *)getNetflixId
+{
+ return [[NSUserDefaults standardUserDefaults] stringForKey:NETFLIXKEY];
+}
+
+- (void)setNetflixId:(NSString *)nid
+{
+ [[NSUserDefaults standardUserDefaults] setObject:nid forKey:NETFLIXKEY];
+}
+
- (void)dealloc {
[networkQueue cancelAllOperations];
[networkQueue release];

0 comments on commit 5a4e5dd

Please sign in to comment.