I'm trying to convert Csv to Json with Php.
This is the Csv source: finance.sina.com. hk/cgi-bin/api/stock.cgi?action=stock&s=1
The value of 's', like example ablove: s=1, can be substituted with any number in order to recieve different stock's data.
And I've done this part (truboy.comeze. com/csv2json.php) :
$set = http_build_query( array( 'action' => 'stock', 's' => '1' ) );
$opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $set ) );
$url = "http://finance.sina.com.hk/cgi-bin/api/stock.cgi";
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
echo $result;
This code actually works. However, the value 's' is fixed with '1' and I want 's' to be changeable
Can I do sth. like 'posting data' e.g.csv2json.php?s=123 ?
Thanks guys!