1// create & initialize a curl session
2$curl = curl_init();
3
4// set our url with curl_setopt()
5curl_setopt($curl, CURLOPT_URL, "api.example.com");
6
7// return the transfer as a string, also with setopt()
8curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
9
10// curl_exec() executes the started curl session
11// $output contains the output string
12$output = curl_exec($curl);
13
14// close curl resource to free up system resources
15// (deletes the variable made by curl_init)
16curl_close($curl);