Précédent   Forum du club des développeurs et IT Pro > Systèmes > Mac > Objective-C
Objective-C Forum d'entraide sur le langage de programmation Objective-C
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 22/01/2013, 18h10   #1
Fooshi
Membre habitué
 
Avatar de Fooshi
 
Homme
Inscription : juin 2002
Messages : 389
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : juin 2002
Messages : 389
Points : 133
Points : 133
Par défaut Authentification htaccess webservice

Bonjour,
j'ai une fonction qui va effectuer une requete asynchrone pour lire un json mais sur le serveur il y a un htaccess, je ne peux donc pas lire le json.
comment faire une authentification ?
voici ma fonction de connection :


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-(BOOL) _sendAsynchronousRequestWithStringURL:(NSString*)stringURL method:(NSString*)method attachedData:(NSData*)attachedData delegate:(id<WebServiceDelegate>)delegate andKey:(id)key{
    if (stringURL == nil){
        return NO;
    }
    
	// Create the request
    NSURL * url = [[NSURL alloc] initWithString:[stringURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
	NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:timeoutInterval];
    [url release];
    [request setHTTPMethod:method];
    
    //Si des donnees sont attachees
    if (attachedData){
        [request addValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
        [request setHTTPBody: attachedData];
    }
    
	// Send the request asynchronously
	NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    
    
    //[request release];
    
    if (!connection){
        return NO;
    }
    
    //On sauvegarde les infos de la connection
    WebServiceConnection * webServiceConnection = [[WebServiceConnection alloc] initWithConnection:connection delegate:delegate andKey:key];
    
	NSValue * connectionKey = [NSValue valueWithNonretainedObject:connection];
    [connections setObject:webServiceConnection forKey:connectionKey];
    
    NSLog(@"Ouverture d'une connection internet (total %d) pour l'adresse : %@", [connections count], stringURL); 
    
    [webServiceConnection release];    
    [connection release];
    
    return YES;
}
merci d'avance
Fooshi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/01/2013, 20h34   #2
JeitEmgie
Expert Confirmé
 
Homme
Inscription : septembre 2006
Messages : 2 375
Détails du profil
Informations personnelles :
Sexe : Homme

Informations forums :
Inscription : septembre 2006
Messages : 2 375
Points : 2 891
Points : 2 891
Lisez la doc du delegate de NSURLConnection, notamment :

Code :
1
2
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
JeitEmgie est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 23/01/2013, 09h51   #3
Fooshi
Membre habitué
 
Avatar de Fooshi
 
Homme
Inscription : juin 2002
Messages : 389
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : juin 2002
Messages : 389
Points : 133
Points : 133
Merci effectivement j'y suis arrivé merci
Fooshi est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 12h42.


 
 
 
 
Partenaires

Hébergement Web