This repository has been archived by the owner on Dec 14, 2017. It is now read-only.
/
apifunctions.php
54 lines (52 loc) · 1.57 KB
/
apifunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
GeoMaker by Christian Heilmann (api helper functions)
Version: 1.0
Homepage: http://icant.co.uk/geomaker/
Copyright (c) 2009, Christian Heilmann
Code licensed under the BSD License:
http://wait-till-i.com/license.txt
*/
?>
<?php
function makewoeidhash($places){
$foundplaces = array();
foreach($places->document->placeDetails as $p){
$wkey = 'woeid'.$p->place->woeId;
$foundplaces[$wkey]=array(
'name'=>str_replace(', ZZ','',$p->place->name).'',
'type'=>$p->place->type.'',
'woeId'=>$p->place->woeId.'',
'lat'=>$p->place->centroid->latitude.'',
'lon'=>$p->place->centroid->longitude.''
);
}
return $foundplaces;
}
function postToPlacemaker($content){
global $key;
$ch = curl_init();
if(isset($_GET['lang'])){
$lang = '&inputLanguage='.$_GET['lang'];
}
define('POSTURL', 'http://wherein.yahooapis.com/v1/document');
define('POSTVARS', 'appid='.$key.'&documentContent='.urlencode($content).
'&documentType=text/plain&outputType=xml'.$lang);
$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, POSTVARS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$x = curl_exec($ch);
curl_close($ch);
return $x;
}
function grab($url){
$realurl ='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%20%3D%20%22'.urlencode($url).'%22&format=xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $realurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$c = curl_exec($ch);
curl_close($ch);
return $c;
}
?>