I am trying to use a payment gateway api using php and they said api request will post data using curl, my app is using php code and I don't know how to do that in php file... they provide a sample code, but when I tried to copy and paste the code in php file it shows syntax error. Please help me to do that in php. Link for the payment api that i am using is https://paycertify.com/docs/api/gateway/recurring-billing/create-a-subscription/
curl --request POST \
--url https://gateway-api.paycertify.com/api/subscriptions \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'amount=1.00' \
--form 'description=Monthly tennis club signature' \
--form 'start_date=2018-09-07' \
--form 'end_date=2018-10-07' \
--form 'interval=day' \
--form 'card_number=4111111111111111' \
--form 'merchant_subscription_id=MY-ORDER' \
--form 'interval_count=1' \
--form 'card_expiry_month=01' \
--form 'card_expiry_year=2021' \
--form 'card_cvv=999' \
--form 'first_name=John' \
--form 'last_name=Doe' \
--form 'street_address_1=59 N Santa Cruz Avenue' \
--form 'street_address_2=Suite M' \
--form 'city=Los Gatos' \
--form 'state=CA' \
--form 'country=US' \
--form 'mobile_phone=+11231231234' \
--form 'email=support#paycertify.com' \
--form 'merchant_transaction_id=my-order-id-0001' \
--form 'zip=95030'
This exemple is a shell command. If you want to send data to the api, you will need to use the curl php method.
Try something like this
$curlHandler = curl_init();
curl_setopt_array($curlHandler, [
CURLOPT_URL => 'https://gateway-api.paycertify.com/api/subscriptions',//url you want to call
CURLOPT_RETURNTRANSFER => true,//receive server reponse
CURLOPT_POST => true,//Explain you are using the post method
CURLOPT_HTTPHEADER => array("Authorization: Bearer YOUR_API_TOKEN"),
/**
* An array of field you want to send
*/
CURLOPT_POSTFIELDS => [
'amount' => '1.00',
'description' => 'Monthly tennis club signature',
....
],
]);
$response = curl_exec($curlHandler);
curl_close($curlHandler);
echo($response);
Related
I am trying to troubleshoot a symfony's HTTP client request. How can one display the anticipated request as a cURL request such as the following? Thank you
curl -X 'PUT' \
'https://example.com/projects/01GPX8HPBQ54SA11JKWPWFESM6/document_acl' \
-H 'accept: application/ld+json' \
-H 'Authorization: Bearer blaBlaBla' \
-H 'Content-Type: application/ld+json' \
-d '{}'
I want to add product with image in database and add to cart in shopware 6 using API.
I was stuck at upload image when add product. product added successfully but not media image.
I create custom plugin and upload image through that.
Thank you in advance.
A new media entity needs to be created before they can be referenced for a add product api call. I've added a example to create a media and assign it to a product for you, might need to be tweaked to your specifications:
Create Empty Media Entity
curl --request POST \
--url https://127.0.0.1:8000/api/media \
--header 'Authorization: Bearer OAUTH2_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"id": "eb85c29df15c41e8abd79552dce73e9a"
}'
The uuid needs to be unique and unused in shopware.
Upload Media Content
curl --request POST \
--url 'https://127.0.0.1:8000/api/_action/media/eb85c29df15c41e8abd79552dce73e9a/upload?extension=png&fileName=test' \
--header 'Authorization: Bearer OAUTH2_TOKEN' \
--header 'Content-Type: image/png' \
--data 'base64encode(file_get_contents($file))'
The image needs to be base64 encoded and can then be transfered as a request body.
Assign media to product
curl --request PATCH \
--url https://127.0.0.1:8000/api/product/2a88d9b59d474c7e869d8071649be43c \
--header 'Authorization: Bearer OAUTH2_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"coverId": "eb85c29df15c41e8abd79552dce73e9a"
}'
The media can also added via the sync endpoint and/or used as a gallery element.
I am trying to convert the following post request using postman with no luck
> curl "https://192.168.50.52/token" \
> --request POST \
> --include \
> --insecure \
> --header "Content-Type: application/json" \
> --data '["todo.all"]' \
> --user test:test
Set the "secure" => false setting in slim-api if you do not want to use https
I'm using PHP shell_exec to call the Bluemix Text to Speech API and my code is working well except when I call the text with SSML tags like my second code.
How could I use text and SSML in the same data query?
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! <say-as interpret-as="letters">Hello</say-as> This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
Does say-as interpret-as="letters" Hello fragment need the escape slashes around 'letters'?
Unfortunately, Only US-English Allison voice supports Expressive SSML. Isabela, the PT-BR voice, does not support SSML. That's why it's not working.
Reference:
Currently, the service supports expressiveness only for the US English
Allison voice (en-US_AllisonVoice). Using the element with any other
voice returns an error.
I am studying and implementing an api and while following the examples,
Here is the example 1 :
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-d '{"application_id": "2", "auth_key": "DtF9cZPqTF8Wy9Q", "timestamp": "1333630580", "nonce": "1340569516", "signature": "13293a5bd2026b957ebbb36c89d9649aae9e5503", "user": {"login": "injoit", "password": "injoit"}}' \
https://api.quickblox.com/session.json
For the above example i consructed my get method as
https://api.quickblox.com/session.json?token=re8d22c6e617133ffeadd761193a6c57d87bfb1a0f&application_id=23995&auth_key=CbRasu4Wftu25Qw&nonce=8796×tamp=1434446627&signature=667ee2b448a5d3dd57d112afef3f84dd6c67e165
and it is working good.
But for the below example
curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 17f6a337b0656c9c7e983f9705d79562fc694c0e" \
-H "Content-Type: application/json" \
-d '{"push_token": {"environment": "production", "client_identification_sequence": "aa557232bc237245ba67686484efab"},
"device": {" platform": "iOS", "udid": "5f5930e927660e6e7d8ff0548b3c404a4d16c04f"}}' \
http://api.quickblox.com/push_tokens.json
How can i create the get method. As this has two main arrays i am little confused.
Can anyone help in creating how can i use this call ?
It should be something like this:
https://api.quickblox.com/push_tokens.json?push_token[environment]=production&push_token[client_identification_sequence]=aa557232bc237245ba67686484efab&device[platform]=iOS&device[udid]=5f5930e927660e6e7d8ff0548b3c404a4d16c04f