简体   繁体   中英

what is curl -u equivalent in php unirest

what is curl -u equivalent in php unirest

Blockscore API:

$ curl https://api.blockscore.com/people \
  -u sk_test_n5049aa6053c9a0217bea78070fbf501: \
  --header "Accept: application/vnd.blockscore+json;version=4"

Api key: sk_test_n5049aa6053c9a0217bea78070fbf501

I want to try this out in Unirest . but what is -u ? is it a header or a post?

The -u flag for cURL is used to set the credentials for HTTP Basic authentication. The provided credentials will be base64-encoded and presented in the "Authorization" header as in:

Authorization: Basic c2tfdGVzdF9uNTA0OWFhNjA1M2M5YTAyMTdiZWE3ODA3MGZiZjUwMTo=

So it is a header.

In unirest you should be able to use:

Unirest\Request::auth('sk_test_n5049aa6053c9a0217bea78070fbf501', '');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM