• 01-09-2020, 23:23:16
    #1
    Selam arkadaşlar, json ile aram pek iyi değil. Aşağıdaki dönen sonuçta, batchRequestId'yi php ile değişkene alıp, yeni bir istek yapmam gerek. Ama batchRequestId'yi değişkene aktaramadım bir türlü.

    Dönen json kodu şu şekilde.
    https://paste.ofcode.org/LNjTXPstSK37HTkJRRRYzs
  • 01-09-2020, 23:25:33
    #2
    $json = json_decode($json_verisi, true);
    $batchRequestId = $json['batchRequestId'];
  • 01-09-2020, 23:26:06
    #3
    <?php

    // Declare multi-dimensional array
    $value = array(
    "name"=>"GFG",
    array(
    "email"=>"abc@gfg.com",
    "mobile"=>"XXXXXXXXXX"
    )
    );

    // Use json_encode() function
    $json = json_encode($value);

    // Display the output
    echo($json);

    ?>






    Output:{"name":"GFG","0":{"email":"abc@gfg.com","mobile": "XXXXXXXXXX"}}
  • 01-09-2020, 23:27:20
    #4
    bulutaylak adlı üyeden alıntı: mesajı görüntüle
    Selam arkadaşlar, json ile aram pek iyi değil. Aşağıdaki dönen sonuçta, batchRequestId'yi php ile değişkene alıp, yeni bir istek yapmam gerek. Ama batchRequestId'yi değişkene aktaramadım bir türlü.

    Dönen json kodu şu şekilde.
    https://paste.ofcode.org/LNjTXPstSK37HTkJRRRYzs
    <?php
    $JsonDecode = json_decode('{"batchRequestId":"0936a0c7-897e-4324-a8e6-656f6a48887a-1598925578"}');
    print $JsonDecode->batchRequestId;
  • 01-09-2020, 23:36:15
    #5
    BySocial adlı üyeden alıntı: mesajı görüntüle
    $json = json_decode($json_verisi, true);
    $batchRequestId = $json['batchRequestId'];
    Verdiğim örnek üzerinden denedim çalıştı (json verisi değişkendeydi) ama bir datayı güncellediğim zaman yine json formatında ekrana çıktı verdi. Kodlarım aşağıda nerede yanlış yapıyorum acaba? link ve keyi buraya eklemek için kaldırdım.

    $url = 'link_burada';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    $header = array("Authorization: Basic ". base64_encode("key_burada"), "Content-Type: application/json");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    $result = curl_exec($ch);
    $json = json_decode($result, true);
    echo $batchRequestId = $json['batchRequestId'];
    Dönen sonuç yine şu şekilde;

    {"batchRequestId":"be7c82b7-9020-4dce-87d7-97304sc71c6a-1599006753"}
  • 01-09-2020, 23:41:56
    #6
    bulutaylak adlı üyeden alıntı: mesajı görüntüle
    Verdiğim örnek üzerinden denedim çalıştı (json verisi değişkendeydi) ama bir datayı güncellediğim zaman yine json formatında ekrana çıktı verdi. Kodlarım aşağıda nerede yanlış yapıyorum acaba? link ve keyi buraya eklemek için kaldırdım.

    $url = 'link_burada';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    $header = array("Authorization: Basic ". base64_encode("key_burada"), "Content-Type: application/json");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    $result = curl_exec($ch);
    $json = json_decode($result, true);
    echo $batchRequestId = $json['batchRequestId'];
    Dönen sonuç yine şu şekilde;

    {"batchRequestId":"be7c82b7-9020-4dce-87d7-97304sc71c6a-1599006753"}
    curl'u bitirmeyi unutmuşsunuz hocam.
  • 01-09-2020, 23:46:20
    #7
    BySocial adlı üyeden alıntı: mesajı görüntüle
    curl'u bitirmeyi unutmuşsunuz hocam.
    Şu şekilde bitirdim ama sonuç yine aynı hocam.

    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    $result = curl_exec($ch);
    curl_close($ch);
    
    $json = json_decode($result, true);
    echo $batchRequestId = $json['batchRequestId'];
  • 01-09-2020, 23:48:01
    #8
    bulutaylak adlı üyeden alıntı: mesajı görüntüle
    Şu şekilde bitirdim ama sonuç yine aynı hocam.

    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    $result = curl_exec($ch);
    curl_close($ch);
    
    $json = json_decode($result, true);
    echo $batchRequestId = $json['batchRequestId'];
    $batchRequestId = $json['batchRequestId'];
    echo $batchRequestId;

    Bu şekilde yapın hocam.
  • 01-09-2020, 23:50:00
    #9
    BySocial adlı üyeden alıntı: mesajı görüntüle
    $batchRequestId = $json['batchRequestId'];
    echo $batchRequestId;

    Bu şekilde yapın hocam.
    Yine aynı sonuç