Answers for "php curl https"

PHP
8

php curl post

// set post fields
$post = [
    'username' => 'user1',
    'password' => 'passuser1',
    'gender'   => 1,
];

$ch = curl_init('http://www.example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

// execute!
$response = curl_exec($ch);

// close the connection, release resources used
curl_close($ch);

// do anything you want with your response
var_dump($response);
Posted by: Guest on May-15-2020
1

php curl example

function getUrl($url){
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}
Posted by: Guest on June-26-2019
1

curl get request php

$headers = array(
            'Content-Type: application/json',
            "x-access-token: $token"
        );
        $urlPost = "/child/all";
        $url = "ip/apiurl"
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($curl);
        curl_close($curl);
        $jsonObject = json_decode($response);
        return $jsonObject;
Posted by: Guest on June-28-2021
0

curl request php

$data = array(
            "userId" => "1"
        );

        $headers = array(
            'Content-Type: application/json'
        );
        $url = "ip/api";
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($curl);
        curl_close($curl);
        $jsonObject = json_decode($response);
        return $jsonObject;
Posted by: Guest on June-28-2021

Browse Popular Code Answers by Language