Commit 3b87983a9b1de022aa24a2d0c26286934cde6079
1 parent
263da077
Exists in
master
and in
7 other branches
--no commit message
Showing
3 changed files
with
110 additions
and
74 deletions
Show diff stats
ferramentas/identifica/twitter.php
| ... | ... | @@ -4,66 +4,85 @@ |
| 4 | 4 | <link rel="stylesheet" type="text/css" href="../../css/i3geo45.css.php"> |
| 5 | 5 | <style> |
| 6 | 6 | p { |
| 7 | -color:#2F4632; | |
| 8 | -font-family:Verdana,Arial,Helvetica,sans-serif; | |
| 9 | -font-size:12px; | |
| 10 | -text-align:left; | |
| 7 | + color: #2F4632; | |
| 8 | + font-family: Verdana, Arial, Helvetica, sans-serif; | |
| 9 | + font-size: 12px; | |
| 10 | + text-align: left; | |
| 11 | 11 | } |
| 12 | 12 | </style> |
| 13 | 13 | </head> |
| 14 | -<body style="background-color:white;margin:10px"> | |
| 15 | -<?php | |
| 16 | -if(empty($_GET["km"])) | |
| 17 | -{$km = 5;} | |
| 18 | -else | |
| 19 | -{$km = $_GET["km"];} | |
| 20 | -$par = $_GET["x"].",".$_GET["y"]; | |
| 21 | -echo "<p class=paragrafo >Raio de <input type=text size=4 value='$km' id=km onchange='recarrega($par,this.value)'> km</p>"; | |
| 22 | -include("../../classesphp/carrega_ext.php"); | |
| 23 | -$s = PHP_SHLIB_SUFFIX; | |
| 24 | -if(!function_exists('curl_init')) | |
| 25 | -{@dl( 'php_curl'.'.'.$s );} | |
| 26 | -if(!function_exists('curl_init')) | |
| 27 | -{echo "curl não instalado";return;} | |
| 28 | -$curl = curl_init(); | |
| 29 | -curl_setopt ($curl, CURLOPT_URL, "http://search.twitter.com/search.json?geocode=".$_GET["y"].",".$_GET["x"].",".$km."km"); | |
| 30 | -//teste | |
| 31 | -//curl_setopt ($curl, CURLOPT_URL, "http://search.twitter.com/search.json?geocode=37.781157,-122.398720,2km"); | |
| 32 | -curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
| 33 | -$result = curl_exec($curl); | |
| 34 | -curl_close ($curl); | |
| 35 | -$result = fixEncoding($result); | |
| 36 | -$result = json_decode( $result, true ); | |
| 14 | +<body style="background-color: white; margin: 10px"> | |
| 15 | + <?php | |
| 16 | + if(empty($_GET["km"])) | |
| 17 | + { | |
| 18 | + $km = 5; | |
| 19 | + } | |
| 20 | + else | |
| 21 | + {$km = $_GET["km"]; | |
| 22 | + } | |
| 23 | + $par = $_GET["x"].",".$_GET["y"]; | |
| 24 | + echo "<p class=paragrafo >Raio de <input type=text size=4 value='$km' id=km onchange='recarrega($par,this.value)'> km</p>"; | |
| 25 | + include("../../classesphp/carrega_ext.php"); | |
| 26 | + include("../../ms_configura.php"); | |
| 27 | + $s = PHP_SHLIB_SUFFIX; | |
| 28 | + if(!function_exists('curl_init')) | |
| 29 | + { | |
| 30 | + @dl( 'php_curl'.'.'.$s ); | |
| 31 | + } | |
| 32 | + if(!function_exists('curl_init')) | |
| 33 | + { | |
| 34 | + echo "curl não instalado";return; | |
| 35 | + } | |
| 37 | 36 | |
| 38 | -//echo "<pre>"; | |
| 39 | -//var_dump($result); | |
| 37 | + $ch = curl_init(); | |
| 38 | + curl_setopt($ch,CURLOPT_URL, 'https://api.twitter.com/oauth2/token'); | |
| 39 | + curl_setopt($ch,CURLOPT_POST, true); | |
| 40 | + $data = array(); | |
| 41 | + $data['grant_type'] = "client_credentials"; | |
| 42 | + curl_setopt($ch,CURLOPT_POSTFIELDS, $data); | |
| 43 | + $consumerKey = $twitteroauth["consumerkey"]; //add your app key | |
| 44 | + $consumerSecret = $twitteroauth["consumersecret"]; //add your app secret | |
| 45 | + curl_setopt($ch,CURLOPT_USERPWD, $consumerKey . ':' . $consumerSecret); | |
| 46 | + curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); | |
| 47 | + $result = curl_exec($ch); | |
| 48 | + curl_close($ch); | |
| 49 | + | |
| 50 | + $bearer_token = json_decode($result); | |
| 51 | + $bearer = $bearer_token->{'access_token'}; // this is your app token | |
| 52 | + | |
| 53 | + $curl = curl_init(); | |
| 54 | + curl_setopt($curl,CURLOPT_URL, "https://api.twitter.com/1.1/search/tweets.json?geocode=".$_GET["y"].",".$_GET["x"].",".$km."km"); | |
| 55 | + curl_setopt($curl,CURLOPT_HTTPHEADER,array('Authorization: Bearer ' . $bearer)); | |
| 56 | + curl_setopt($curl,CURLOPT_RETURNTRANSFER, true); | |
| 57 | + | |
| 58 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
| 59 | + $result = curl_exec($curl); | |
| 60 | + curl_close ($curl); | |
| 61 | + $result = fixEncoding($result); | |
| 62 | + $result = json_decode( $result, true ); | |
| 40 | 63 | |
| 41 | -if(isset($result["error"]) || count($result["results"]) == 0) | |
| 42 | -{ | |
| 43 | - echo "Nada encontrado"; | |
| 44 | -} | |
| 45 | -else | |
| 46 | -{ | |
| 47 | 64 | $html = "<table class='lista4'>"; |
| 48 | - foreach($result["results"] as $r) | |
| 49 | - { | |
| 50 | - | |
| 51 | - $html .= "<tr><td><img src='".$r["profile_image_url"]."' /></td>"; | |
| 52 | - $html .= "<td><a href='http://twitter.com/".$r["from_user"]."' target=_blank '>".$r["from_user"]."</a><br>"; | |
| 65 | + foreach($result["statuses"] as $r) | |
| 66 | + { | |
| 67 | + $usuario = $r["user"]; | |
| 68 | + $html .= "<tr><td><img src='".$usuario["profile_image_url"]."' /></td>"; | |
| 69 | + $html .= "<td><a href='http://twitter.com/".$usuario["screen_name"]."' target=_blank '>".$usuario["screen_name"]."</a><br>"; | |
| 53 | 70 | $html .= "<span style=color:gray >".$r["created_at"]."</span><br>"; |
| 54 | 71 | $html .= $r["text"]."<br></td></tr>"; |
| 55 | 72 | } |
| 56 | 73 | echo $html."</table>"; |
| 57 | -} | |
| 58 | -function fixEncoding($in_str) | |
| 59 | -{ | |
| 60 | - $cur_encoding = mb_detect_encoding($in_str) ; | |
| 61 | - if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")) | |
| 62 | - {return $in_str;} | |
| 63 | - else | |
| 64 | - {return utf8_encode($in_str);} | |
| 65 | -} | |
| 66 | -?> | |
| 74 | + function fixEncoding($in_str) | |
| 75 | + { | |
| 76 | + $cur_encoding = mb_detect_encoding($in_str) ; | |
| 77 | + if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")) | |
| 78 | + { | |
| 79 | + return $in_str; | |
| 80 | + } | |
| 81 | + else | |
| 82 | + {return utf8_encode($in_str); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + ?> | |
| 67 | 86 | </body> |
| 68 | 87 | <script> |
| 69 | 88 | function recarrega(x,y,km){ | ... | ... |
ferramentas/identifica/twitterplaces.php
| ... | ... | @@ -19,19 +19,34 @@ if(!function_exists('curl_init')) |
| 19 | 19 | {@dl( 'php_curl'.'.'.$s );} |
| 20 | 20 | if(!function_exists('curl_init')) |
| 21 | 21 | {echo "curl não instalado";} |
| 22 | -$curl = curl_init(); | |
| 23 | -//lista de places | |
| 24 | -curl_setopt ($curl, CURLOPT_URL, "http://api.twitter.com/1/geo/nearby_places.json?lat=".$_GET["y"]."&long=".$_GET["x"]."&accuracy=0&granularity=neighborhood"); | |
| 25 | -curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
| 26 | -$result = curl_exec($curl); | |
| 27 | -curl_close ($curl); | |
| 22 | +include("../../ms_configura.php"); | |
| 23 | + | |
| 24 | + | |
| 25 | +$ch = curl_init(); | |
| 26 | +curl_setopt($ch,CURLOPT_URL, 'https://api.twitter.com/oauth2/token'); | |
| 27 | +curl_setopt($ch,CURLOPT_POST, true); | |
| 28 | +$data = array(); | |
| 29 | +$data['grant_type'] = "client_credentials"; | |
| 30 | +curl_setopt($ch,CURLOPT_POSTFIELDS, $data); | |
| 31 | +$consumerKey = $twitteroauth["consumerkey"]; //add your app key | |
| 32 | +$consumerSecret = $twitteroauth["consumersecret"]; //add your app secret | |
| 33 | +curl_setopt($ch,CURLOPT_USERPWD, $consumerKey . ':' . $consumerSecret); | |
| 34 | +curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); | |
| 35 | +$result = curl_exec($ch); | |
| 36 | +curl_close($ch); | |
| 37 | + | |
| 38 | +$bearer_token = json_decode($result); | |
| 39 | +$bearer = $bearer_token->{'access_token'}; // this is your app token | |
| 40 | + | |
| 41 | +$curl = curl_init(); | |
| 42 | +curl_setopt($curl,CURLOPT_URL, "https://api.twitter.com/1.1/geo/reverse_geocode.json?lat=".$_GET["y"]."&long=".$_GET["x"]."&accuracy=0&granularity=neighborhood"); | |
| 43 | +curl_setopt($curl,CURLOPT_HTTPHEADER,array('Authorization: Bearer ' . $bearer)); | |
| 44 | +curl_setopt($curl,CURLOPT_RETURNTRANSFER, true); | |
| 45 | +$result = curl_exec($curl); | |
| 46 | +curl_close ($curl); | |
| 28 | 47 | $result = fixEncoding($result); |
| 29 | 48 | $result = json_decode( $result, true ); |
| 30 | -/* | |
| 31 | -echo "<pre>"; | |
| 32 | -var_dump($result); | |
| 33 | -exit; | |
| 34 | -*/ | |
| 49 | + | |
| 35 | 50 | if(isset($result["error"]) || count($result["result"]["places"]) == 0) |
| 36 | 51 | { |
| 37 | 52 | echo "Nada encontrado"; |
| ... | ... | @@ -41,8 +56,8 @@ else |
| 41 | 56 | $html = "<table class='lista4'>"; |
| 42 | 57 | $places = $result["result"]["places"]; |
| 43 | 58 | foreach($places as $p) |
| 44 | - { | |
| 45 | - | |
| 59 | + { | |
| 60 | + | |
| 46 | 61 | $html .= "<tr>"; |
| 47 | 62 | $html .= "<td><a href='http://search.twitter.com/search?q=place:".$p["id"]."' target=_self '>".$p["full_name"]."</a><br>"; |
| 48 | 63 | $html .= "<span style=color:gray >".$p["place_type"]."</span>"; |
| ... | ... | @@ -57,6 +72,6 @@ function fixEncoding($in_str) |
| 57 | 72 | {return $in_str;} |
| 58 | 73 | else |
| 59 | 74 | {return utf8_encode($in_str);} |
| 60 | -} | |
| 75 | +} | |
| 61 | 76 | ?> |
| 62 | 77 | </body> |
| 63 | 78 | \ No newline at end of file | ... | ... |
temas/_lubs.map
| ... | ... | @@ -2,17 +2,19 @@ MAP |
| 2 | 2 | FONTSET "../symbols/fontes.txt" |
| 3 | 3 | SYMBOLSET "../symbols/simbolos.sym" |
| 4 | 4 | LAYER |
| 5 | - CONNECTION "user=guest_sala password= dbname=dbspo host= port=5432" | |
| 5 | + CONNECTION "user=guest_sala password= dbname=dbspo host=10.1.2.25 port=5432" | |
| 6 | 6 | CONNECTIONTYPE POSTGIS |
| 7 | 7 | DATA "the_geom from ( |
| 8 | 8 | SELECT |
| 9 | - st_geomfromtext('POINT(' || dbgeral.tb_estab_geo.long || ' ' || dbgeral.tb_estab_geo.lat || ')', 4326)as the_geom, | |
| 10 | - dbsismob.tb_sismob_unid_func.no_unidade, | |
| 11 | - tb_sismob_unid_func.co_cnes as gid, | |
| 12 | - dbgeral.tb_ibge.uf, | |
| 13 | - dbgeral.tb_ibge.cidade, | |
| 14 | - dbacoes_saude.tb_cnes_estabelecimento.no_logradouro, | |
| 15 | - dbacoes_saude.tb_cnes_estabelecimento.no_bairro | |
| 9 | + st_geomfromtext('POINT(' || dbgeral.tb_estab_geo.long || ' ' || dbgeral.tb_estab_geo.lat || ')', 4326) as the_geom, | |
| 10 | + 'UBS - '||dbsismob.tb_sismob_unid_func.no_unidade||' - cnes:'||tb_sismob_unid_func.co_cnes as nome, | |
| 11 | + dbgeral.tb_ibge.uf | |
| 12 | + ||' ,' | |
| 13 | + ||dbgeral.tb_ibge.cidade | |
| 14 | + ||' ,' | |
| 15 | + ||dbacoes_saude.tb_cnes_estabelecimento.no_logradouro | |
| 16 | + ||' ,'||dbacoes_saude.tb_cnes_estabelecimento.no_bairro as desc, | |
| 17 | + tb_sismob_unid_func.co_cnes as cnes | |
| 16 | 18 | FROM |
| 17 | 19 | dbsismob.tb_sismob_unid_func |
| 18 | 20 | INNER JOIN dbacoes_saude.tb_cnes_estabelecimento ON |
| ... | ... | @@ -21,8 +23,8 @@ MAP |
| 21 | 23 | ON dbsismob.tb_sismob_unid_func.co_ibge = dbgeral.tb_ibge.ibge |
| 22 | 24 | INNER JOIN dbgeral.tb_estab_geo |
| 23 | 25 | ON dbsismob.tb_sismob_unid_func.co_cnes = dbgeral.tb_estab_geo.co_cnes |
| 24 | - WHERE dbsismob.tb_sismob_unid_func.co_sismob_programa = 1 limit 100 | |
| 25 | - ) as foo using unique gid using srid=4326" | |
| 26 | + WHERE dbsismob.tb_sismob_unid_func.co_sismob_programa = 1 limit 500 | |
| 27 | + ) as foo using unique cnes using srid=4326" | |
| 26 | 28 | METADATA |
| 27 | 29 | "METAESTAT_ID_MEDIDA_VARIAVEL" "" |
| 28 | 30 | "CLASSE" "SIM" | ... | ... |