Greg,
It looks like the code (in jetchJSONObjectForURL) is using a shortcut
method of grabbing data from the web with
NSString:initWithContentsOfURL: which creates an NSString from the
contents at a specific URL ( go figure! ). I'm not sure if that method
utilizes the credential store, if not you would need to expand the code
to get the data explicitly with a NSURLConnection (Like is done in the
updateStatus function)
You can register a set of credentials with the credential storage system
before you make the NSURLConnection call like so:
NSURLCredential *credential =
[NSURLCredential credentialWithUser:username
password:password
persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace =
[[NSURLProtectionSpace alloc] initWithHost:@"twitter.com"
port:0
protocol:@"http"
realm:nil
authenticationMethod:nil];
[[NSURLCredentialStorage sharedCredentialStorage]
setDefaultCredential:credential
forProtectionSpace:protectionSpace];
Now that the credentials are stored you are free to make your call using
NSURLConnection (verbatim from your code):
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
Also, change this line:
NSURL *url = [NSURL URLWithString:[NSString
stringWithFormat:@"http://%@:%@@twitter.com/statuses/update.json",
username, password]];
to this:
NSURL *url = [NSURL
URLWithString:@"http://twitter.com/statuses/update.json"];
Josh
Doug Williams wrote:
> Guys, this is a little out of my realm of expertise. Any Objective-C
> folks out there able to lend Greg a hand?
>
> Greg, if no one responds soon, I'll roll my sleeves up and play around
> with the source...
>
> Doug Williams
> Twitter API Support
> http://twitter.com/dougw
>
>
>
> On Tue, Mar 10, 2009 at 3:04 PM, Greg Maletic <[email protected]> wrote:
>
>> On Mar 10, 6:54 am, Doug Williams <[email protected]> wrote:
>>
>>> Can you tell me which library you are using?
>>>
>> It's just a basic library that was given as part of a class at
>> Stanford on iPhone development. If you want to download the source, it
>> can be downloaded from
>> http://www.stanford.edu/class/cs193p/cgi-bin/index.php;
>> download the file called Presence4Files.zip.
>>
>>
>>
>>> Also, can you include sample code of the request you are making (obscure
>>> your credentials of course)?
>>>
>> The request made by the Objective-C method I'm calling is:
>>
>>
>> http://[username]:[[email protected]/statuses/user_timeline/[username].json?since_id=[id]
>>
>> If I leave off the since_id, it works as expected. When I specify the
>> since_id, it still works, but it doesn't honor the since_id in any
>> way.
>>
>> Thanks very much,
>>
>> Greg
>>
>>