dongshuo2752 2018-08-28 13:13
浏览 210
已采纳

将curl响应保存到数据库中

I am getting this response

[{"id":15702671,"payment_id":15702666,"amount":20,"metadata":{},"source":{"id":"347862165","name":"Test Test","type":"collector"},"date_created":"2018-08-28T08:11:15.000-04:00","unique_sequence_number":null,"status":"approved"}]

This is my Code

$url = "https://api.mercadopago.com/v1/payments/".$paymeny_id."/refunds?access_token=TEST-4015220099523401-082300-232be80199d9b1a9b0bac72d6af99fd2-347862165";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

how to save response value in variable ?

  • 写回答

2条回答 默认 最新

  • douwei7471 2018-08-28 13:15
    关注

    try this

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $var = curl_exec($ch)
    

    Hope this works!

    to get the id

    $var = json_decode($var);
    $id = $var[0]->id;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?