• 17-05-2020, 06:21:55
    #1
    Merhaba herkese,
    php curl post ile sonuç elde edemedim bir türlü sebebini de anlayamadım artık yorgunluktan da bitkin düştüm. yardım rica ediyorum.
    $data_array = array(
    'hash' => $hash,
    'querytype' => "alternate",
    'type' => "videoGet"
    );
    // $json = json_encode($data_array);
    // $data = array('JSON' => $json);
    $body = http_build_query($data_array);
    $ch = curl_init();
    $url = 'https://site.com/ajax/service';
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Host: site.com",
    "Content-Type: application/x-www-form-urlencoded",
    "Accept: application/json, text/javascript, */*; q=0.01",
    "Accept-Language: tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3",
    "Accept-Encoding: gzip, deflate, br",
    "X-Requested-With: XMLHttpRequest",
    "Origin: https://site.com",
    "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0",
    "Connection: keep-alive"
    ));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($body));
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode(json_encode($result));
    ya 400 bad requst e düşüyor ya da sonuç vermiyor.
  • 17-05-2020, 06:27:19
    #2
    tam url ve data vermen lazım
  • 17-05-2020, 06:39:33
    #3
    Tam veri lazım ona
  • 17-05-2020, 11:25:50
    #4
    Neron adlı üyeden alıntı: mesajı görüntüle
    tam url ve data vermen lazım
    Mr_information adlı üyeden alıntı: mesajı görüntüle
    Tam veri lazım ona
    kodun tamamını mesaj olarak attım zaten tamamında sadece site adresleri gözüküyor bir farkı yok.
    https://paste2.org/pBsAC3jL
  • 17-05-2020, 14:31:17
    #5
    curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($body));

    buradaki urlencode fonksiyonunu kullanmadan deneyin.
  • 17-05-2020, 14:46:39
    #6
    çok denedim ama şimdi çözdüm.
    $data_array = array(
    'hash' => $hash,
    'querytype' => "alternate",
    'type' => "videoGet"
    );
    $ch = curl_init();
    
    $data = http_build_query($data_array);
    curl_setopt($ch, CURLOPT_URL, 'https://site.com);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
    
    $headers = array();
    $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0';
    $headers[] = 'Accept: */*';
    $headers[] = 'Accept-Language: tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3';
    $headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
    $headers[] = 'X-Requested-With: XMLHttpRequest';
    $headers[] = 'Origin: https://site.com';
    $headers[] = 'Connection: keep-alive';
    $headers[] = 'Pragma: no-cache';
    $headers[] = 'Cache-Control: no-cache';
    $headers[] = 'Te: Trailers';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);
    return $result;