what is curl -u equivalent in php unirest - php

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', '');

Related

Verify if token not expired Github Oauth1

Hey i want know if github have a endpoint to verify if a access_token have expired ?
I have tried this but i have a 404 error
404 would mean you did not authenticate properly.
Make sure to use a PAT (Personal Access Token) to authenticate your query (assuming you are not testing you own PAT itself!)
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \ <==== Important
https://api.github.com/applications/Iv1.8a61f9b3a7aba766/token \
-d '{"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a"}'

Cloudflare API - Curl request to block IP with IP Access Rules

I manually block IP to access my site (dlandroid.com) with Cloudflare "IP Access Rules",
My question is how to block an IP with Cloudflare API Curl request using PHP?
I search API document and find this but don't know how to use it with PHP:
curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules?page=1&per_page=20&mode=challenge&configuration.target=ip&configuration.value=198.51.100.4&notes=my note&match=all&order=mode&direction=desc" \
-H "X-Auth-Email: user#example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json"
also check this: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-list-access-rules

Microsoft-Cognitive Text Translation API

AZURE - The official documentation and examples for PHP is not working, help?
I am using the code at this link:
https://github.com/courtney7/HTTP-Code-Samples/blob/37a4431f75397e1ccc6ee3f62ef14b3909a2dc85/PHP/PHPAzureToken.php
Always test and debug APIs using curl (i.e. take a curl first approach). Here's an example that works on my Windows 10 system. Here's the curl that gets a token.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>"
Example to get token and call text translate.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>" > Bearer.txt
set /p Bearer= < Bearer.txt
curl -H "Authorization: Bearer %Bearer%" "https://api.microsofttranslator.com/v2/Http.svc/Translate?Text=Hello+world.&From=en&To=es"
Make sure you are calling the correct endpoint "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"

Retrieve user information from paypal in php using ios sdk

https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/profile_sharing_server.md#profile-sharing-server-side-integration
curl 'https://api.paypal.com/v1/oauth2/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic QWZVa...==" \
-d 'grant_type=refresh_token&refresh_token=MFYQ...'
What is
Authorization: Basic QWZVa...== ??
and retur true;
Authorization: Basic xxxx is the OAuth 2 auth token. Basic is the token type, and the xxxx piece is your access token. It's a way of authorizing a user, and will be passed in the headers of a request. More info here: https://developer.paypal.com/docs/api/#authentication--headers

Add Curl -u in POSTMAN

I try to do the next Request. but i cant find how to put '-u' in POSTMAN UI param.
Where can I put the -u param in the Program.
$ curl https://core.spreedly.com/v1/gateways.json
-u 'Ll6fAtoVSTyVMlJEmtpoJV8S:R3SD2XD4Io5VXmyzdCtTivHFTTSy'
-H 'Content-Type: application/json' \
-d '{
"gateway": {
"gateway_type": "test"
}
}'
The -u option in cURL performs Basic Authentication, where you can effectively "sign in" to an API by using a username and password.
You can add Basic Authentication to your Postman request under Authentication > Basic Auth. In your example, the text before the : in the -u option is the username and the text after is the password.

Categories