gpt4 book ai didi

ios - 将 curl 请求转换为 AFNetworking 2.0

转载 作者:行者123 更新时间:2023-11-28 22:21:23 25 4
gpt4 key购买 nike

我正在使用 Balanced Payments API,在他们的示例代码中,他们这样发出 curl 请求:

curl https://api.balancedpayments.com/v1/customers \
-u ak-test-PE0kAimMqYDGzebPIHUzYwuLUM86yCxP: \
-X POST

我不确定如何在 AFNetworking 2.0 库中传递 -u 值。

引用:Balanced Payments API

To authenticate with Balanced, you will need the API key secret provided from the dashboard. You have to use http basic access authentication. Your key has to be set as the username. A password is not required for simplicity.

最佳答案

AFHTTPRequestOperation *operation = // …
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"ak-test-PE0kAimMqYDGzebPIHUzYwuLUM86yCxP:" password:@"unused" persistence:NSURLCredentialPersistenceForSession];
[operation setCredential:credential];

持久化选项 are listed here .

关于ios - 将 curl 请求转换为 AFNetworking 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20292048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com