Quantcast
Channel: Executing Curl in PHP to do a Stripe subscription - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Executing Curl in PHP to do a Stripe subscription

$
0
0

The Stripe API allows for Curl calls to be made. For example, the command:

curl https://api.stripe.com//v1/customers/cus_5ucsCmNxF3jsSY/subscriptions    -u sk_test_REDACTED:

returns the subscription of customer cus_5ucsCmNxF3jsSY.

How can I use PHP to call this curl command (I am trying to avoid using the PHP Stripe libraries).

I am trying the following:

<?php         // create curl resource         $ch = curl_init();         // set url         curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com//v1/customers/cus_5ucsCmNxF3jsSY/subscriptions    -u sk_test_REDACTED:");         //return the transfer as a string         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);         // $output contains the output string         $output = curl_exec($ch);         print($output);        // close curl resource to free up system resources         curl_close($ch);      ?>

However, it seems that curl does not take the -u parameter of the URL. I get the following error:

{ "error": { "type": "invalid_request_error", "message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/." } 

How can I pass the -u sk_test_REDACTED: parameter to my curl call?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images