Skip to content

Instantly share code, notes, and snippets.

@AnowarCST
Last active August 29, 2015 14:18
Show Gist options
  • Save AnowarCST/0a0cbb5d4c1dccf16bc3 to your computer and use it in GitHub Desktop.
Save AnowarCST/0a0cbb5d4c1dccf16bc3 to your computer and use it in GitHub Desktop.
Using Curl in PHP
<?php
// header('Content-Type: application/xml; charset=utf-8');
// header('Content-Type: application/json');
// Page Name : index.php
$params = array(
"apiKey" => "30aNowar50Hossain42",
"User" => "anowar",
"token" => "1001",
"student" => "anowar",
"roll" => "305042",
"dept" => "CST",
"mobile" => "01822141954"
);
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "http://localhost/API_Rnd/myTestAPI.php/apiKey",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $params
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment