Closed ghost closed 7 years ago
Ok i figured it out *bash_head even though its not the result that i like
<?php $url_send ="http://ogre.adc4gis.com/convertJson";
function sendPostData($url){
$data = file_get_contents('data/tes_data.js');
$str_data = json_decode($data, true);
$file = fopen('data/item.zip','w+');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_POSTFIELDS,"json=$data");
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
// return $result;
}
echo " " . sendPostData($url_send);
?>
I make a dummy zip file for downloading..
Hi and Hello Wavded. I develope a website application and using ogr2ogr on my localhost via npm. I did try using CURL for converting geojson files to shapefiles but to no avail it returns some weird text. I can't download the Zip Files.
PKVH.IOGRGeoJSON.dbfc�g�bd``hd�$�@8C^bn*T�D�)J�e�T�D����8�畤b��Up��/*Vp�L�IQ�pJ,NMJ��Q.IL�,ͥ�̐��b *�H-JU(�HU�O��L-V(�I�T$�xPK���wrPKVH.IOGRGeoJSON.prjsw�ww�V�������&J:.�!���J.HB��A��.�Jef�����:F�zF��FFƦfƱ�:A���@��E��y���J:�:�~�!@3SӁ�@=CsSc#K#SCKK �46PK��Qjy�PKVH.IOGRGeoJSON.shpc
P�b�^0300����9�>��}�c����|��QDA�pa3PK����-�PKVH.IOGRGeoJSON.shxcP�b��^0300����9�>��}�c����|��QD��<.PKχy�+lPKVH.I���wr ��OGRGeoJSON.dbfPKVH.I��Qjy� ���OGRGeoJSON.prjPKVH.I����-� ��hOGRGeoJSON.shpPKVH.Iχy�+l ���OGRGeoJSON.shxPK�8
I also did try using POST Request to live website and it returns same result. I'm currently new with this..is there anything wrong or maybe you can point me the correct ways? Thanks in a bunch.
Here are the codes :
'<?php
$data = file_get_contents('data/tes_data.js'); $url_send ="http://localhost:3000/convertJson"; $str_data = json_encode($data);
$ch = curl_init($url_send); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); curl_setopt($ch, CURLOPT_POSTFIELDS, 'json=$data'); curl_setopt($ch, CURLOPT_POSTFIELDS, 'skipFailures=1'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec($ch); var_dump($str_data); return $result; curl_close($ch); ?>'
the tes_data.js are some examples:
'{ "type": "Feature", "properties": { "name": "Coors Field", "amenity": "Baseball Stadium", "popupContent": "This is where the Rockies play!" }, "geometry": { "type": "Point", "coordinates": [-104.99404, 39.75621] } }'