2015-01-08 34 views
0

我很新的翹曲,我需要發送POST請求到以下網址:獲得訪問令牌的條紋支付網關在PHP

curl -X POST https://connect.stripe.com/oauth/token \ -d client_secret=Secret key \ -d code=AUTHORIZATION_CODE \ -d grant_type=authorization_code

在我將收到的響應從條帶訪問令牌。 請讓我知道如何在php中使用php-cURL創建函數。

感謝您的幫助。

+0

你見過這個要點:https://gist.github.com/amfeng/3507366? – koopajah

+0

感謝koopajah會嘗試這個,如果它的成功。 – laracaster

回答

1

條紋可能會建議使用他們的庫,但這是我今天早上在這裏玩的捲曲工具;我更喜歡捲曲在庫,在其周圍包裹任何一天:

$post = 'client_secret='.$system['stipe']['client_secret'].'&grant_type=authorization_code&code='.$_GET['code']; 
$ch = curl_init(); 
curl_setopt($ch,CURLOPT_URL, $system['stipe']['token_url']); 
curl_setopt($ch,CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$result = curl_exec($ch); 
curl_close($ch); 

你只需要包起來的功能和json_decode返回的值。

這適用於我,而docs/gist中的代碼並不像他們缺乏SSL驗證對等設備上的錯誤標誌,在我的開發設置中,它使事情變得尷尬。

+0

非常感謝這個工作!!!!。 – laracaster

+0

爲你的開發設置禁用是好的,但你絕對不應該建議'curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,0);'在生產中我認爲 – koopajah