svn: /web/presentations/trunk/ hacku.xml slides/intro/placemaker.php slides/intro/placemaker.xml slides/intro/ws4.xml

From: Date: Thu, 10 Sep 2009 22:02:54 +0000
Subject: svn: /web/presentations/trunk/ hacku.xml slides/intro/placemaker.php slides/intro/placemaker.xml slides/intro/ws4.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1595@lists.php.net to get a copy of this message
rasmus Thu, 10 Sep 2009 22:02:54 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288250 Log: Initial Placemaker example Changed paths: U web/presentations/trunk/hacku.xml A web/presentations/trunk/slides/intro/placemaker.php A web/presentations/trunk/slides/intro/placemaker.xml U web/presentations/trunk/slides/intro/ws4.xml Modified: web/presentations/trunk/hacku.xml =================================================================== --- web/presentations/trunk/hacku.xml 2009-09-10 21:58:00 UTC (rev 288249) +++ web/presentations/trunk/hacku.xml 2009-09-10 22:02:54 UTC (rev 288250) @@ -47,6 +47,7 @@ <slide>slides/intro/rss_flickr.xml</slide> <slide>slides/intro/ws4.xml</slide> +<slide>slides/intro/placemaker.xml</slide> <slide>slides/intro/php_js1.xml</slide> <slide>slides/intro/php_js2.xml</slide> Added: web/presentations/trunk/slides/intro/placemaker.php =================================================================== --- web/presentations/trunk/slides/intro/placemaker.php (rev 0) +++ web/presentations/trunk/slides/intro/placemaker.php 2009-09-10 22:02:54 UTC (rev 288250) @@ -0,0 +1,55 @@ +<?php +$q = isset($_POST['q']) ? trim($_POST['q']) : ''; +if(!strlen($q) && isset($_GET['q'])) $q = trim($_GET['q']); +$type = 'text/plain'; +?> +<html><head><title>Placemaker Test</title></head> +<body> +<h3>Paste a blurb of text, or a URL to fetch text from (Max 50KB)</h3> +<form action="placemaker.php" method="POST"> +<textarea name="q" cols=100 rows=10><?php echo htmlspecialchars($q)?></textarea><br><br> +<input type="submit"> +</form> +<?php +if(strlen($q)) { + if(substr(strtolower($q),0,4)=='http') { + // If we have a URL, send a HEAD request to pick up the content-type + $opts = array('http'=>array('method'=>"HEAD")); + $context = stream_context_create($opts); + $tmp = file_get_contents($q,false,$context); + foreach($http_response_header as $v) { + list($key,$value) = explode(':',$v); + if(strtolower(trim($key))=='content-type') { + list($tmp,$junk) = explode(';',$value,2); + $type = trim($tmp); + } + } + $find = 'documentURL='.$q; + } else { + $find = 'documentContent='.rawurlencode($q); + } + file_put_contents("/var/tmp/pl.log",$q."\n", FILE_APPEND); // Logging queries + $url = 'http://wherein.yahooapis.com/v1/document'; + $post = "appid=Gux4Z8LIkY1IKfVXnRcMegs3IjNfmUhl&documentType=$type&$find"; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + $data = curl_exec($ch); + curl_close($ch); + $xml = new DOMDocument; + $xml->preserveWhiteSpace = false; + $xml->loadXML($data); + $xml->formatOutput = true; // Make the XML look pretty + $data = $xml->saveXML(); + $tmpf = tempnam('/var/tmp','pl'); + file_put_contents($tmpf,$data); + echo "<pre>"; + echo /usr/local/bin/code2html --no-header -lhtml -t 4 $tmpf; // Syntax highlighting + echo "</pre>"; + unlink($tmpf); +} +?> +</body> +</html> Property changes on: web/presentations/trunk/slides/intro/placemaker.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: web/presentations/trunk/slides/intro/placemaker.xml =================================================================== --- web/presentations/trunk/slides/intro/placemaker.xml (rev 0) +++ web/presentations/trunk/slides/intro/placemaker.xml 2009-09-10 22:02:54 UTC (rev 288250) @@ -0,0 +1,6 @@ +<slide title="Placemaker"> +<break lines="1" /> +<link marginleft="1em" fontsize="4em" href="http://developer.yahoo.com/geo/placemaker"/> +<example title="placemaker.php" filename="placemaker.php" hide="0" result="0" fontsize="1.5em" marginright="0em"/> +<example title="" filename="placemaker.php" hide="1" result="1" marginright="0em" type="iframe"/> +</slide> Property changes on: web/presentations/trunk/slides/intro/placemaker.xml ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: web/presentations/trunk/slides/intro/ws4.xml =================================================================== --- web/presentations/trunk/slides/intro/ws4.xml 2009-09-10 21:58:00 UTC (rev 288249) +++ web/presentations/trunk/slides/intro/ws4.xml 2009-09-10 22:02:54 UTC (rev 288250) @@ -13,6 +13,8 @@ <bullet>Flickr</bullet> <bullet>Maps</bullet> <bullet>Geocoding</bullet> +<bullet>Placemaker</bullet> +<bullet>YQL</bullet> <bullet>Context Extraction Service</bullet> </list>

« previous php.pres (#1595) next »