Skip to content

Instantly share code, notes, and snippets.

@prahladyeri
Created December 24, 2016 16:17
Show Gist options
  • Save prahladyeri/f81121046a918ae7e999d38abc27379e to your computer and use it in GitHub Desktop.
Save prahladyeri/f81121046a918ae7e999d38abc27379e to your computer and use it in GitHub Desktop.
<?php
//Fetching the latest value of BSE-Sensex in just 9 lines of PHP code:
$data = http_build_query(array("client"=>"ig", "q" => 'BSE:SENSEX'));
$url = "http://finance.google.com/finance/info?";
$ch = curl_init();
$curlConfig = array( CURLOPT_URL => $url.$data, CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
$result = substr($result,3);
print_r( json_decode($result)[0]->l); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment