php - cURL using info from mySQL, then storing the cURL'ed info (articles and guides is much appreciated!) -


maybe simple thing - me it's quite hard!

for starters, i'm new programming in php (been doing time time @ university when needed)and i've tried reading sorts of guides , articles on curl subject.

those i've found usefull until how curl through 1 site lot of information, need how on multiple sites not information - few lines, matter of fact!

another part is, article focus @ storing @ ftp server in txt file, have loaded around 900 addresses mysql, , want load them there, , enrich table information stored in links - provided beneath!

we have open public libraries addresses , information these , api.

link main site:

the function use: http://dawa.aws.dk/adresser/autocomplete?q=

sql structure: enter image description here data example: http://i.imgur.com/jp1j26u.jpg

fx addresse: dornen 2 6715 esbjerg n (called adrname in databasen).

http://dawa.aws.dk/adresser/autocomplete?q=dornen%202%206715%20esbjerg%20n

this give me following output (which want store in adrid in database):

[ {   "tekst": "dornen 2, tarp, 6715 esbjerg n",   "adresse": {     "id": "0a3f50b8-d085-32b8-e044-0003ba298018",     "href": "http://dawa.aws.dk/adresser/0a3f50b8-d085-32b8-e044-0003ba298018",     "vejnavn": "dornen",     "husnr": "2",     "etage": null,     "dør": null,     "supplerendebynavn": "tarp",     "postnr": "6715",     "postnrnavn": "esbjerg n"   } } ] 

for now, want store in blob, seen in sql structure, i'm little off.. can kick me in right direction guide, article - helped by? :)

if want make curl request in php use method

function curl_download($url){  // curl installed yet? if (!function_exists('curl_init')){     die('sorry curl not installed!'); }  // ok cool - let's create new curl resource handle $ch = curl_init();  // set options (most optional)  // set url download curl_setopt($ch, curlopt_url, $url);  // set referer curl_setopt($ch, curlopt_referer, "http://www.example.org/yay.htm");  // user agent curl_setopt($ch, curlopt_useragent, "mozillaxyz/1.0");  // include header in result? (0 = yes, 1 = no) curl_setopt($ch, curlopt_header, 0);  // should curl return or print out data? (true = return, false = print) curl_setopt($ch, curlopt_returntransfer, true);  // timeout in seconds curl_setopt($ch, curlopt_timeout, 10);  // download given url, , return output $output = curl_exec($ch);  // close curl resource, , free system resources curl_close($ch);  return $output; } 

and call using

print curl_download('http://dawa.aws.dk/adresser/autocomplete?q=melvej'); 

or can directly convert json object

$jsonstring=curl_download('http://dawa.aws.dk/adresser/autocomplete?q=melvej');  var_dump(json_decode($jsonstring)); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -