Prodej brandové domény světové značky Fred Perry
Zobrazují se odpovědi 1 až 3 z 3

Php curl a put

  1. Zdravim

    neviete ako do php curl cez http PUT napisat na na priklade takuto poziadku:

    URL: https://nieco.com
    JSON data:

    {
    "ips": [
    "111.111.111.111"
    ]
    }

  2. Co se právě děje na Webtrhu?
  3. <?php

    // get cURL resource
    $ch = curl_init();

    // set url
    curl_setopt($ch, CURLOPT_URL, 'https://nieco.com/');

    // set method
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    // return the transfer as a string
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // set headers
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    ]);

    // json body
    $json_array = [
    'ips' => [
    '111.111.111.111'
    ]
    ];
    $body = json_encode($json_array);

    // set body
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

    // send the request and save response to $response
    $response = curl_exec($ch);

    // stop if fails
    if (!$response) {
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
    }

    echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
    echo 'Response Body: ' . $response . PHP_EOL;

    // close curl resource to free up system resources
    curl_close($ch);

  4. vdaka velmy pekny funguje to :)

    Citace Původně odeslal obchodniuspech Zobrazit příspěvek
    <?php

    // get cURL resource
    $ch = curl_init();

    // set url
    curl_setopt($ch, CURLOPT_URL, 'https://nieco.com/');

    // set method
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

    // return the transfer as a string
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // set headers
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    ]);

    // json body
    $json_array = [
    'ips' => [
    '111.111.111.111'
    ]
    ];
    $body = json_encode($json_array);

    // set body
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

    // send the request and save response to $response
    $response = curl_exec($ch);

    // stop if fails
    if (!$response) {
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
    }

    echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
    echo 'Response Body: ' . $response . PHP_EOL;

    // close curl resource to free up system resources
    curl_close($ch);

Spolupracujeme: Jooble.org, Aximum - profesionální překlady Hostujeme u Server powered by TELE3