Objective-c HTTP Basic authentication

后端 未结 3 1916
青春惊慌失措
青春惊慌失措 2021-02-06 09:29

How would i go about replicating this in objective-c

curl -u rick@email.com:mypassword http://foo.lighthouseapp.com/projects.xml

I\'ve been pla

3条回答
  •  旧时难觅i
    2021-02-06 09:57

    From ASIHTTPRequest Documentation

    With a Request Header

    [request addRequestHeader:@"Authorization"
                        value:[NSString stringWithFormat:@"Basic %@",
                               [ASIHTTPRequest base64forData:
                                [[NSString stringWithFormat:@"%@:%@", theUsername, thePassword]
                                 dataUsingEncoding:NSUTF8StringEncoding]]]];
    

提交回复
热议问题