cvs: presentations /slides/intro hacku_ref.xml rss_flickr.xml ws4.xml yql.xml yql2.xml
| From: | Rasmus Lerdorf | Date: | Tue, 17 Feb 2009 22:41:45 +0000 |
| Subject: | cvs: presentations /slides/intro hacku_ref.xml rss_flickr.xml ws4.xml yql.xml yql2.xml | ||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1536@lists.php.net to get a copy of this message | ||
rasmus Tue Feb 17 22:41:45 2009 UTC
Added files:
/presentations/slides/intro yql.xml
Modified files:
/presentations/slides/intro hacku_ref.xml rss_flickr.xml ws4.xml
yql2.xml
Log:
Updated HackU talk
http://cvs.php.net/viewvc.cgi/presentations/slides/intro/hacku_ref.xml?r1=1.3&r2=1.4&diff_format=u
Index: presentations/slides/intro/hacku_ref.xml
diff -u presentations/slides/intro/hacku_ref.xml:1.3 presentations/slides/intro/hacku_ref.xml:1.4
--- presentations/slides/intro/hacku_ref.xml:1.3 Fri Jan 30 18:39:37 2009
+++ presentations/slides/intro/hacku_ref.xml Tue Feb 17 22:41:45 2009
@@ -2,7 +2,8 @@
<break lines="1" />
<link fontsize="3em" marginleft="2em" leader="Slides: "
href=":-:url:-:"/>
<link fontsize="3em" marginleft="2em" leader="HackU: "
href="http://developer.yahoo.com/hacku"/>
-<link fontsize="3em" marginleft="2em" leader="irc: "
href="irc://irc.freenode.net/indiahacku"/>
+<link fontsize="3em" marginleft="2em" leader="irc: "
href="irc://irc.freenode.net/hacku"/>
+<link fontsize="3em" marginleft="2em" leader="YQL: " href="http://developer.yahoo.com/yql/console/"/>
<link fontsize="3em" marginleft="2em" leader="YUI: " href="http://developer.yahoo.com/yui"/>
<link fontsize="3em" marginleft="2em" leader="GeoPlanet: "
href="http://developer.yahoo.com/geo"/>
<link fontsize="3em" marginleft="2em" leader="Maps: "
href="http://developer.yahoo.com/maps"/>
http://cvs.php.net/viewvc.cgi/presentations/slides/intro/rss_flickr.xml?r1=1.2&r2=1.3&diff_format=u
Index: presentations/slides/intro/rss_flickr.xml
diff -u presentations/slides/intro/rss_flickr.xml:1.2 presentations/slides/intro/rss_flickr.xml:1.3
--- presentations/slides/intro/rss_flickr.xml:1.2 Wed Feb 21 23:27:46 2007
+++ presentations/slides/intro/rss_flickr.xml Tue Feb 17 22:41:45 2009
@@ -1,8 +1,13 @@
<slide title="5-second Atom parser">
<break lines="1" />
-<example title="Recent Flickr Photos" fontsize="1.5em"
rfontsize="1em" result="1"><![CDATA[<?php
+<example title="Recent Flickr Photos" fontsize="1.5em"
rfontsize="1em" result="0"><![CDATA[<?php
$url = 'http://www.flickr.com/services/feeds/photos_public.gne';
foreach(simplexml_load_file($url)->entry as $it) echo $it->content;
?>]]></example>
+<example title="Recent Flickr Photos" fontsize="1.5em"
rfontsize="1em" hide="1" result="1"><![CDATA[<?php
+$url = '/Users/rasmus/photos_public.gne';
+foreach(simplexml_load_file($url)->entry as $it) echo $it->content;
+?>]]></example>
+
</slide>
http://cvs.php.net/viewvc.cgi/presentations/slides/intro/ws4.xml?r1=1.10&r2=1.11&diff_format=u
Index: presentations/slides/intro/ws4.xml
diff -u presentations/slides/intro/ws4.xml:1.10 presentations/slides/intro/ws4.xml:1.11
--- presentations/slides/intro/ws4.xml:1.10 Fri Sep 12 21:18:03 2008
+++ presentations/slides/intro/ws4.xml Tue Feb 17 22:41:45 2009
@@ -2,7 +2,6 @@
<list>
<bullet>Web Search</bullet>
<bullet>Web Search with Context</bullet>
-<bullet>MyWeb</bullet>
<bullet>Creative Commons Web Search</bullet>
<bullet>News Search</bullet>
<bullet>Image Search</bullet>
http://cvs.php.net/viewvc.cgi/presentations/slides/intro/yql2.xml?r1=1.1&r2=1.2&diff_format=u
Index: presentations/slides/intro/yql2.xml
diff -u presentations/slides/intro/yql2.xml:1.1 presentations/slides/intro/yql2.xml:1.2
--- presentations/slides/intro/yql2.xml:1.1 Fri Jan 30 18:39:37 2009
+++ presentations/slides/intro/yql2.xml Tue Feb 17 22:41:45 2009
@@ -2,8 +2,6 @@
<break lines="2"/>
-<blurb>Yahoo Query Language</blurb>
-
<example title="XPath on URL using PHP's OAuth Extension" result="1"
fontsize="1.3em" rfontsize="1.3em"><![CDATA[<?php
require './oauth_secret.inc';
$url = 'http://query.yahooapis.com/v1/yql';
@@ -13,14 +11,19 @@
$q = <<<EOB
select * from html where xpath=
'//tr//a[@href="/wiki/Capital_(political)"]/../../../td[2]/a/text()'
-and url in (select url from search .web where url like '%wikipedia%'
- and query='India' limit 1)
+and url in (select url from search.web where url like '%wikipedia%'
+ and query='Denmark' limit 1)
EOB;
$o->fetch("$url?q=".rawurlencode($q)."&format=json");
+/* Uncomment for debugging
$response_info = $o->getLastResponseInfo();
echo "<pre>".print_r($response_info,true)."</pre>";
+*/
$result = json_decode($o->getLastResponse(),true);
- echo "<pre>".print_r($result['query'],true)."</pre>";
+ foreach($result['query']['diagnostics']['url'] as $u) {
+ echo "{$u['content']}<br>\n";
+ }
+ echo "<b>Answer: </b>{$result['query']['results']}";
} catch(Exception $E) {
echo "Error: [".$E->errorMessage."]<br>\n";
echo "Response: [".$E->lastResponse."]<br>\n";
http://cvs.php.net/viewvc.cgi/presentations/slides/intro/yql.xml?view=markup&rev=1.1
Index: presentations/slides/intro/yql.xml
+++ presentations/slides/intro/yql.xml
<slide title="Yahoo Query Language - YQL">
<break lines="1"/>
<blurb fontsize="4em">Combine all APIs on the Web into a single API!</blurb>
<link leader="Docs: " fontsize="3em" marginleft="1em">http://developer.yahoo.com/yql</link>
<link leader="Public URL: " fontsize="3em" marginleft="1em">http://query.yahooapis.com/v1/public/yql</link>
<link leader="OAuth'ed URL: " fontsize="3em"
marginleft="1em">http://query.yahooapis.com/v1/yql</link>
<link leader="Cool Console: " fontsize="3em" marginleft="1em">http://developer.yahoo.com/yql/console/</link>
<example title="Public Flickr Search" result="1"
fontsize="1.4em"><![CDATA[<?php
$url = "http://query.yahooapis.com/v1/public/yql?q=";
$q = "select * from flickr.photos.search(100) where text='hacku'";
$fmt = "xml";
$x = simplexml_load_file($url.urlencode($q)."&format=$fmt");
foreach($x->attributes('http://www.yahooapis.com/v1/base.rng') as
$k=>$v) {
$$k=(string)$v;
}
echo <<<EOB
$count photos fetched from
{$x->diagnostics->url} in
{$x->diagnostics->url['execution-time']} seconds<br>
EOB;
$flickr = "http://static.flickr.com/";
foreach($x->results->photo as $p) {
echo "<img
src=\"$flickr{$p['server']}/{$p['id']}_{$p['secret']}_s.jpg\"/>\n";
}
?>]]></example>
<example title="Add a Cache" result="1"
fontsize="1.4em"><![CDATA[<?php
function cache($url) {
$tmp = '/tmp/'.md5($url);
if(!$fe=file_exists($tmp) || $fe && filemtime($tmp) < (time()-7200)) {
if($fe) touch($tmp);
$stream = fopen($url,'r');
$tmpf = tempnam('/tmp','YWS');
file_put_contents($tmpf, $stream);
fclose($stream);
rename($tmpf, $tmp);
}
return $tmp;
}
$yql = "http://query.yahooapis.com/v1/public/yql?q=";
$q = "use 'http://airports.pidgets.com/v1/tables.xml'
as airports;".
"select * from airports(5) where near='Seattle' and direct_flights_min=20";
$x = simplexml_load_file(cache($yql.urlencode($q).'&format=xml'));
echo "<b>URLs accessed:</b><br>\n";
foreach($x->diagnostics->url as $u) {
echo "<a href=\"$u\">$u</a><br>\n";
}
echo "<br>";
foreach($x->results->airport as $a) {
echo <<<EOB
{$a->code} <a href="{$a->url}">{$a->name}</a>
{$a->dist}km<br>
EOB;
}
?>]]></example>
</slide>