<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sentido Web &#187; PHP</title>
	<atom:link href="http://sentidoweb.com/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://sentidoweb.com</link>
	<description>Desarrollo web, HTML, CSS, Javascript, PHP, MySQL</description>
	<lastBuildDate>Tue, 10 Apr 2012 01:02:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Actualiza tu theme de WordPress desde SVN</title>
		<link>http://sentidoweb.com/2011/10/17/actualiza-tu-theme-de-wordpress-desde-svn.php</link>
		<comments>http://sentidoweb.com/2011/10/17/actualiza-tu-theme-de-wordpress-desde-svn.php#comments</comments>
		<pubDate>Mon, 17 Oct 2011 21:58:14 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2752</guid>
		<description><![CDATA[Si trabajas realizando proyectos en WordPress en el que el código se aloja en un servidor usando SVN, una forma sencilla de actualizar tu theme con los últimos cambios es mediante este sencillo y no-seguro plugin. El plugin añade una opción de menú al Settings del Dashboard de WP, el cual te servirá para indicar [...]]]></description>
			<content:encoded><![CDATA[<p>Si trabajas realizando proyectos en WordPress en el que el código se aloja en un servidor usando SVN, una forma sencilla de actualizar tu theme con los últimos cambios es mediante este sencillo y no-seguro plugin.</p>
<p>El plugin añade una opción de menú al Settings del Dashboard de WP, el cual te servirá para indicar el servidor SVN, usuario, contraseña y el path que corresponde a la carpeta <em>themes</em> de WP. El plugin se conectará al repositorio SVN y recuperará las carpetas que se encuentran en el path anterior y comprobará si las carpetas corresponden a themes instalados, mostrarás una lista con los themes encontrados junto a un botón que permite actualizar todo el theme.</p>
<p>Digo que no es seguro porque no controlo los permisos de los usuarios ni otras cuestiones, pero si estás interesado en ello supongo que no te costará mucho meterle mano al código:</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// Adding Admin menu</span>
<span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span> is_admin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_menu'</span>, <span style="color: #ff0000;">'svn_update_menu'</span><span style="color: #66cc66;">&#41;</span>;
  add_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'admin_init'</span>, <span style="color: #ff0000;">'svn_update_register_settings'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_register_settings<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_username'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_password'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_repository'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_theme_path'</span> <span style="color: #66cc66;">&#41;</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'page'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'svn-update/svn-update.php'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #723b00;">require</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'phpsvnclient/phpsvnclient.php'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$phpsvnclient</span> = <span style="color: #000000; font-weight: bold;">new</span> phpsvnclient<span style="color: #66cc66;">&#40;</span>get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_repository'</span><span style="color: #66cc66;">&#41;</span>, get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_username'</span><span style="color: #66cc66;">&#41;</span>, get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$files</span> = <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getDirectoryFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$svn_themes</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #3E6D8F;">$themes</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span>get_themes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$k</span>=&gt;<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#41;</span> <span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'Template'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$k</span>, <span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"Template Dir"</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'directory'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #3E6D8F;">$svn_themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>;
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    update_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_themes'</span>, <span style="color: #3E6D8F;">$svn_themes</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'svn_update'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #3E6D8F;">$path</span> = <span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'svn_update'</span><span style="color: #66cc66;">&#93;</span>;
      <span style="color: #3E6D8F;">$theme_path</span> = WP_CONTENT_DIR . <span style="color: #ff0000;">'/themes/'</span>;
      <span style="color: #3E6D8F;">$files</span> = <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getDirectoryFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$path</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'file'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          file_put_contents<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$theme_path</span>.<span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getFile</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
      add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_notices'</span>, <span style="color: #ff0000;">'showSVNUpdated'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> showSVNUpdated<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;&lt;p&gt;&lt;strong&gt;Theme updated&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;'</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_menu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  add_options_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SVN Update Options'</span>, <span style="color: #ff0000;">'SVN Update'</span>, <span style="color: #cc66cc;">8</span>, <span style="color: #000000; font-weight: bold;">__FILE__</span>, <span style="color: #ff0000;">'svn_update_options'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_options<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"wrap"</span>&gt;
&lt;h2&gt;SVN Update Options&lt;/h2&gt;
&lt;form method=<span style="color: #ff0000;">"post"</span> action=<span style="color: #ff0000;">"options.php"</span>&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> settings_fields<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_up_option-group'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;table <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"form-table"</span>&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Username&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_username"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_username'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span>/&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_username"</span>&gt;Write your SVN username&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Password&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_password"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_password'); ?&gt;"</span> type=<span style="color: #ff0000;">"password"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_password"</span>&gt;Write your SVN password&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Repository&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_repository"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_repository'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_reposotoy"</span>&gt;for example: &lt;em&gt;http:<span style="color: #808080; font-style: italic;">//domain.com/svn_path/project&lt;/em&gt;&lt;/label&gt;</span>
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Theme path&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_theme_path"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_theme_path'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_theme_path"</span>&gt;for example: &lt;em&gt;/trunk/my_project/themes&lt;/em&gt;&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
&lt;p <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"submit"</span>&gt;
&lt;input type=<span style="color: #ff0000;">"submit"</span> <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"button-primary"</span> value=<span style="color: #ff0000;">"&lt;?php _e('Save Changes') ?&gt;"</span> /&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;h3&gt;Available Themes&lt;/h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #3E6D8F;">$themes</span> = get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_themes'</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;p&gt;No themes found in SVN repository instaled in WordPress&lt;/p&gt;'</span>;
  <span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;ul&gt;'</span>;
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$k</span>=&gt;<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;li&gt;/'</span>.<span style="color: #3E6D8F;">$k</span>.<span style="color: #ff0000;">' =&gt; '</span>.<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">' &lt;a href=&quot;'</span>.admin_url<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'options-general.php?page=svn-update%2Fsvn-update.php&amp;svn_update=/'</span>.<span style="color: #3E6D8F;">$k</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'&quot; class=&quot;button-primary&quot;&gt;Update&lt;/a&gt;&lt;/li&gt;'</span>;
    <span style="color: #66cc66;">&#125;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;/ul&gt;'</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Este plugin necesita la librería <a href="http://code.google.com/p/phpsvnclient/">PHP SVN Client</a> para acceder al SVN, tan solo hay que meterlo en el mismo directorio que el plugin. Le faltan muchas cosas al plugin, pero ni tengo ganas ni tengo tiempo.</p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/10/17/actualiza-tu-theme-de-wordpress-desde-svn.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acceder a Streaming API de PHP</title>
		<link>http://sentidoweb.com/2011/09/29/acceder-a-streaming-api-de-php.php</link>
		<comments>http://sentidoweb.com/2011/09/29/acceder-a-streaming-api-de-php.php#comments</comments>
		<pubDate>Thu, 29 Sep 2011 11:13:34 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2746</guid>
		<description><![CDATA[Para aquellos que necesiten realizar aplicaciones sobre Twitter que tiren de la Streaming API, por ejemplo monitorear o que se dice de una marca, les va a venir muy bien este código: set_time_limit&#40;0&#41;; $query_data = array&#40;'track' =&#62; 'lo que quieres buscar'&#41;; $user = 'username'; // replace with your account $pass = 'password'; // replace with [...]]]></description>
			<content:encoded><![CDATA[<p>Para aquellos que necesiten realizar aplicaciones sobre Twitter que tiren de la Streaming API, por ejemplo monitorear o que se dice de una marca, les va a venir muy bien este código:</p>
<pre><code><pre class="php"><a href="http://www.php.net/set_time_limit"><span style="color: #000066;">set_time_limit</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
 
<span style="color: #3E6D8F;">$query_data</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'track'</span> =&gt; <span style="color: #ff0000;">'lo que quieres buscar'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$user</span> = <span style="color: #ff0000;">'username'</span>;	<span style="color: #808080; font-style: italic;">// replace with your account</span>
<span style="color: #3E6D8F;">$pass</span> = <span style="color: #ff0000;">'password'</span>;	<span style="color: #808080; font-style: italic;">// replace with your account</span>
 
<span style="color: #3E6D8F;">$fp</span> = <a href="http://www.php.net/fsockopen"><span style="color: #000066;">fsockopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"stream.twitter.com"</span>, <span style="color: #cc66cc;">80</span>, <span style="color: #3E6D8F;">$errno</span>, <span style="color: #3E6D8F;">$errstr</span>, <span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"$errstr ($errno)<span style="color: #000099; font-weight: bold;">\n</span>"</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #3E6D8F;">$request</span> = <span style="color: #ff0000;">"GET /1/statuses/filter.json?"</span> . http_build_query<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$query_data</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">" HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<span style="color: #3E6D8F;">$request</span> .= <span style="color: #ff0000;">"Host: stream.twitter.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<span style="color: #3E6D8F;">$request</span> .= <span style="color: #ff0000;">"Authorization: Basic "</span> . <a href="http://www.php.net/base64_encode"><span style="color: #000066;">base64_encode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$user</span> . <span style="color: #ff0000;">':'</span> . <span style="color: #3E6D8F;">$pass</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span>, <span style="color: #3E6D8F;">$request</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #723b00;">while</span><span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/feof"><span style="color: #000066;">feof</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #3E6D8F;">$json</span> = <a href="http://www.php.net/fgets"><span style="color: #000066;">fgets</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #3E6D8F;">$data</span> = json_decode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$json</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//</span>
			<span style="color: #808080; font-style: italic;">// Do something with the data!</span>
			<span style="color: #808080; font-style: italic;">//</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>El parámetro <em>track</em> se puede cambiar por <em>follow</em> (usando IDs numéricos) para saber que dice algún usuario y que dicen los que le mencionan o retuitean.</p>
<p>Vía / <a href="http://af-design.com/blog/2010/12/17/reading-the-twitter-stream-api-with-php/">AF-Design</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/09/29/acceder-a-streaming-api-de-php.php/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Añadir clase a la imagen destacada de WordPress según el tamaño</title>
		<link>http://sentidoweb.com/2011/09/14/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php</link>
		<comments>http://sentidoweb.com/2011/09/14/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php#comments</comments>
		<pubDate>Wed, 14 Sep 2011 17:07:07 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[post_thumbnail_html]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2739</guid>
		<description><![CDATA[Hace bastante que no escribía, sobre todo por falta de tiempo, pero quería escribir sobre este pequeño truco de WordPress. Cuando añadimos una imagen destacada en un post de WordPress nos podemos encontrar con que la imagen ocupa todo el ancho (lo más normal) o que no ocupa tanto, con lo que nos encontramos que [...]]]></description>
			<content:encoded><![CDATA[<p>Hace bastante que no escribía, sobre todo por falta de tiempo, pero quería escribir sobre este pequeño truco de WordPress. Cuando añadimos una imagen destacada en un post de WordPress nos podemos encontrar con que la imagen ocupa todo el ancho (lo más normal) o que no ocupa tanto, con lo que nos encontramos que la imagen queda muy sola y el diseño queda feo.</p>
<p>Para solucionar esto, deberemos añadir un filtro, comprobar el tamaño de la imagen y el del ancho del contenido y en el caso de que creamos que es conveniente (por ejemplo la mitad del ancho del contenido) añadir una clase a la imagen:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> mi_post_thumbnail_html<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$html</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// Se suele recomendar definir la variable $content_width para ocasiones como esta</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$content_width</span>;
  <a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#width=&quot;([^&quot;]+)&quot;#'</span>, <span style="color: #3E6D8F;">$html</span>, <span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> &lt; <span style="color: #3E6D8F;">$content_width</span>/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#class=&quot;([^&quot;]+)&quot;#'</span>, <span style="color: #3E6D8F;">$html</span>, <span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">"right"</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #723b00;">return</span> <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'class=&quot;'</span>.<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">'&quot;'</span>, <span style="color: #ff0000;">'class=&quot;'</span>.<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">' right&quot;'</span>, <span style="color: #3E6D8F;">$html</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #723b00;">return</span> <span style="color: #3E6D8F;">$html</span>;
<span style="color: #66cc66;">&#125;</span>
add_filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'post_thumbnail_html'</span>, <span style="color: #ff0000;">'mi_post_thumbnail_html'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/09/14/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Librería PHP para TwitPic</title>
		<link>http://sentidoweb.com/2011/05/31/libreria-php-para-twitpic.php</link>
		<comments>http://sentidoweb.com/2011/05/31/libreria-php-para-twitpic.php#comments</comments>
		<pubDate>Tue, 31 May 2011 21:45:39 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[twitpic]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2729</guid>
		<description><![CDATA[TwitPic es un servicio que se utiliza para subir fotos que luego publicas en Twitter. Si estás realizando una aplicación que tira de Twitter y quieres dar la oportunidad al usuario de subir sus fotos puedes hacer uso de esta aplicación y su API (es necesario darse de alta): $twitpic = new TwitPic&#40;$api_key, $consumer_key, $consumer_secret, [...]]]></description>
			<content:encoded><![CDATA[<p>TwitPic es un servicio que se utiliza para subir fotos que luego publicas en Twitter. Si estás realizando una aplicación que tira de Twitter y quieres dar la oportunidad al usuario de subir sus fotos puedes hacer uso de esta aplicación y su API (es necesario darse de alta):</p>
<pre><code><pre class="php"><span style="color: #3E6D8F;">$twitpic</span> = <span style="color: #000000; font-weight: bold;">new</span> TwitPic<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$api_key</span>, <span style="color: #3E6D8F;">$consumer_key</span>, <span style="color: #3E6D8F;">$consumer_secret</span>, <span style="color: #3E6D8F;">$oauth_token</span>, <span style="color: #3E6D8F;">$oauth_secret</span><span style="color: #66cc66;">&#41;</span>;
try <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">/*
  * Retrieves all images where the user is facetagged
  */</span>
  <span style="color: #3E6D8F;">$user</span> = <span style="color: #3E6D8F;">$twitpic</span>-&gt;<span style="color: #006600;">faces</span>-&gt;<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'user'</span>=&gt;<span style="color: #ff0000;">'meltingice'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$user</span>-&gt;<span style="color: #006600;">images</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #3E6D8F;">$media</span> = <span style="color: #3E6D8F;">$twitpic</span>-&gt;<span style="color: #006600;">media</span>-&gt;<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'id'</span>=&gt;<span style="color: #cc66cc;">1234</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #3E6D8F;">$media</span>-&gt;<span style="color: #006600;">message</span>;
&nbsp;
  <span style="color: #3E6D8F;">$user</span> = <span style="color: #3E6D8F;">$twitpic</span>-&gt;<span style="color: #006600;">users</span>-&gt;<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'username'</span>=&gt;<span style="color: #ff0000;">'meltingice'</span><span style="color: #66cc66;">&#41;</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'process'</span>=&gt;false, <span style="color: #ff0000;">'format'</span>=&gt;<span style="color: #ff0000;">'xml'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #3E6D8F;">$user</span>; <span style="color: #808080; font-style: italic;">// raw XML response data</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*
  * Uploads an image to TwitPic
  */</span>
  <span style="color: #3E6D8F;">$resp</span> = <span style="color: #3E6D8F;">$twitpic</span>-&gt;<span style="color: #006600;">upload</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'media'</span>=&gt;<span style="color: #ff0000;">'path/to/file.jpg'</span>, <span style="color: #ff0000;">'message'</span>=&gt;<span style="color: #ff0000;">'This is an example'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$resp</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #808080; font-style: italic;">/*
  * Uploads an image to TwitPic AND posts a tweet
  * to Twitter.
  *
  * NOTE: this still uses v2 of the TwitPic API. This means that the code makes 2 separate
  * requests: one to TwitPic for the image, and one to Twitter for the tweet. Because of this,
  * understand this call may take a bit longer than simply uploading the image.
  */</span>
  <span style="color: #3E6D8F;">$resp</span> = <span style="color: #3E6D8F;">$twitpic</span>-&gt;<span style="color: #006600;">uploadAndPost</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'media'</span>=&gt;<span style="color: #ff0000;">'path/to/file.jpg'</span>, <span style="color: #ff0000;">'message'</span>=&gt;<span style="color: #ff0000;">'Another example'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$resp</span><span style="color: #66cc66;">&#41;</span>;
  
<span style="color: #66cc66;">&#125;</span> catch <span style="color: #66cc66;">&#40;</span>TwitPicAPIException <span style="color: #3E6D8F;">$e</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #3E6D8F;">$e</span>-&gt;<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p><a href="https://github.com/meltingice/TwitPic-API-for-PHP">TwitPic API for PHP</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/05/31/libreria-php-para-twitpic.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpcassa: librería PHP para Cassandra</title>
		<link>http://sentidoweb.com/2011/04/13/phpcassa-libreria-php-para-cassandra.php</link>
		<comments>http://sentidoweb.com/2011/04/13/phpcassa-libreria-php-para-cassandra.php#comments</comments>
		<pubDate>Wed, 13 Apr 2011 08:34:27 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[phpcassa]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2713</guid>
		<description><![CDATA[Aunque (afortunadamente) Cassandra ya no está tan de moda y en boca de todos, sigue siendo una herramienta a tener en cuenta a la hora de desarrollar un proyecto en el que se calcule un elevado nivel de datos. Para los que usamos PHP nos vendrá muy bien esta librería que nos facilitará el trabajo [...]]]></description>
			<content:encoded><![CDATA[<p>Aunque (afortunadamente) Cassandra ya no está tan de moda y en boca de todos, sigue siendo una herramienta a tener en cuenta a la hora de desarrollar un proyecto en el que se calcule un elevado nivel de datos. Para los que usamos PHP nos vendrá muy bien esta librería que nos facilitará el trabajo y que además es compatible con <em>TimeUUID</em> y <em>SuperColumnFamily</em>:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #808080; font-style: italic;">// Copiar todos los ficheros en el directorio</span>
<a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'THRIFT_ROOT'</span>, <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">'/include/thrift/'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #723b00;">require_once</span> THRIFT_ROOT.<span style="color: #ff0000;">'/packages/cassandra/Cassandra.php'</span>;
<span style="color: #723b00;">require_once</span> THRIFT_ROOT.<span style="color: #ff0000;">'/transport/TSocket.php'</span>;
<span style="color: #723b00;">require_once</span> THRIFT_ROOT.<span style="color: #ff0000;">'/protocol/TBinaryProtocol.php'</span>;
<span style="color: #723b00;">require_once</span> THRIFT_ROOT.<span style="color: #ff0000;">'/transport/TFramedTransport.php'</span>;
<span style="color: #723b00;">require_once</span> THRIFT_ROOT.<span style="color: #ff0000;">'/transport/TBufferedTransport.php'</span>;
<span style="color: #723b00;">include_once</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">'/include/phpcassa.php'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #723b00;">include_once</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">'/include/uuid.php'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Setting up nodes:</span>
CassandraConn::<span style="color: #006600;">add_node</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'192.168.1.1'</span>, <span style="color: #cc66cc;">9160</span><span style="color: #66cc66;">&#41;</span>;
CassandraConn::<span style="color: #006600;">add_node</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'192.168.1.2'</span>, <span style="color: #cc66cc;">5000</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Create a column family object</span>
<span style="color: #3E6D8F;">$users</span> = <span style="color: #000000; font-weight: bold;">new</span> CassandraCF<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Keyspace1'</span>, <span style="color: #ff0000;">'Users'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// ColumnFamily</span>
<span style="color: #3E6D8F;">$super</span> = <span style="color: #000000; font-weight: bold;">new</span> CassandraCF<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Keyspace1'</span>, <span style="color: #ff0000;">'SuperColumn'</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// SuperColumnFamily</span>
<span style="color: #808080; font-style: italic;">// Inserting:</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">insert</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'email'</span> =&gt; <span style="color: #ff0000;">'email@correo.com'</span>, <span style="color: #ff0000;">'password'</span> =&gt; <span style="color: #ff0000;">'test'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Querying:</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// array('email' =&gt; 'email@correo.com', 'password' =&gt; 'test')</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">multiget</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span>, <span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// array('1' =&gt; array('email' =&gt; 'email@correo.com', 'password' =&gt; 'test'))</span>
<span style="color: #808080; font-style: italic;">// Removing:</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// removes whole object</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span>, <span style="color: #ff0000;">'password'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// removes 'password' field</span>
<span style="color: #808080; font-style: italic;">// Other:</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">get_count</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// counts the number of columns in user 1 (in this case 2)</span>
<span style="color: #3E6D8F;">$users</span>-&gt;<span style="color: #006600;">get_range</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1'</span>, <span style="color: #ff0000;">'10'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// gets all users between '1' and '10'</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></code></pre>
<p><a href="https://github.com/hoan/phpcassa">phpcassa</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/04/13/phpcassa-libreria-php-para-cassandra.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Crear thumbs con WordPress</title>
		<link>http://sentidoweb.com/2011/04/02/crear-thumbs-con-wordpress.php</link>
		<comments>http://sentidoweb.com/2011/04/02/crear-thumbs-con-wordpress.php#comments</comments>
		<pubDate>Sat, 02 Apr 2011 20:56:37 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[thumbs]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2709</guid>
		<description><![CDATA[Si antes hablaba de una librería que crea thumbs con PHP, ahora comento cómo hacerlo con WordPress, ya que a veces es necesario subir ficheros cuando WP se utiliza para algo más que un simple blog: // uploadfile tiene el path del fichero subido // el cuarto par&#195;&#161;metro es para que haga crop $thumb = [...]]]></description>
			<content:encoded><![CDATA[<p>Si antes hablaba de <a href="http://sentidoweb.com/2011/04/02/php-thumbnailer-libreria-para-crear-thumbs-de-imagenes.php">una librería que crea thumbs con PHP</a>, ahora comento cómo hacerlo con WordPress, ya que a veces es necesario subir ficheros cuando WP se utiliza para algo más que un simple blog:</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// uploadfile tiene el path del fichero subido</span>
<span style="color: #808080; font-style: italic;">// el cuarto par&Atilde;&iexcl;metro es para que haga crop</span>
<span style="color: #3E6D8F;">$thumb</span> = image_resize<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$uploadfile</span>, <span style="color: #3E6D8F;">$width</span>, <span style="color: #3E6D8F;">$height</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #3E6D8F;">$upload</span> = wp_upload_dir<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$thumburl</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$upload</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #3E6D8F;">$upload</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#93;</span>,  <span style="color: #3E6D8F;">$thumb</span> <span style="color: #66cc66;">&#41;</span>;</pre></code></pre>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/04/02/crear-thumbs-con-wordpress.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Thumbnailer: librería para crear thumbs de imágenes</title>
		<link>http://sentidoweb.com/2011/04/02/php-thumbnailer-libreria-para-crear-thumbs-de-imagenes.php</link>
		<comments>http://sentidoweb.com/2011/04/02/php-thumbnailer-libreria-para-crear-thumbs-de-imagenes.php#comments</comments>
		<pubDate>Sat, 02 Apr 2011 18:38:03 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[imágenes]]></category>
		<category><![CDATA[thumbs]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2706</guid>
		<description><![CDATA[Si hay algo que odio a la hora de desarrollar una aplicación es tener que hacer thumbs de las imágenes, sobre todo para los perfiles: que si el thumb es cuadrado y la imagen rectangular, que si se debe recortar o meter bordes, &#8230; PHP Thumbnailer nos facilita enormemente esta tarea: Hacer resize: try &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>Si hay algo que odio a la hora de desarrollar una aplicación es tener que hacer thumbs de las imágenes, sobre todo para los perfiles: que si el thumb es cuadrado y la imagen rectangular, que si se debe recortar o meter bordes, &#8230; <strong>PHP Thumbnailer</strong> nos facilita enormemente esta tarea:</p>
<p>Hacer resize:</p>
<pre><code><pre class="php">try <span style="color: #66cc66;">&#123;</span>
     <span style="color: #3E6D8F;">$thumb</span> = PhpThumbFactory::<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/path/to/image.jpg'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span> catch <span style="color: #66cc66;">&#40;</span>Exception <span style="color: #3E6D8F;">$e</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     <span style="color: #808080; font-style: italic;">// error</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #3E6D8F;">$thumb</span>-&gt;<span style="color: #006600;">resize</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$thumb</span>-&gt;<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p>Hacer resize y crop si es rectangular:</p>
<pre><code><pre class="php"><span style="color: #3E6D8F;">$thumb</span>-&gt;<span style="color: #006600;">adaptiveResize</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">175</span>, <span style="color: #cc66cc;">175</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$thumb</span>-&gt;<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/path/to/new_image.jpg'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p><a href="http://phpthumb.gxdlabs.com/">PHP Thumbnailer</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/04/02/php-thumbnailer-libreria-para-crear-thumbs-de-imagenes.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Subir y exportar documentos usando Google Docs y PHP</title>
		<link>http://sentidoweb.com/2011/03/27/subir-y-exportar-documentos-usando-google-docs-y-php.php</link>
		<comments>http://sentidoweb.com/2011/03/27/subir-y-exportar-documentos-usando-google-docs-y-php.php#comments</comments>
		<pubDate>Sun, 27 Mar 2011 18:46:43 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[exportar]]></category>
		<category><![CDATA[google docs]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[ppt]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2703</guid>
		<description><![CDATA[Uno de los problemas con los que nos podemos encontrar es tener un documento en un formato y tener que exportarlo en otro formato. La exportación se puede realizar utilizando Google Docs, quizás un tanto rebuscada la solución, aunque quizás no tanto. Os paso un script que sube el fichero a Google Docs dentro de [...]]]></description>
			<content:encoded><![CDATA[<p>Uno de los problemas con los que nos podemos encontrar es tener un documento en un formato y tener que exportarlo en otro formato. La exportación se puede realizar utilizando Google Docs, quizás un tanto rebuscada la solución, aunque quizás no tanto.</p>
<p>Os paso un script que sube el fichero a Google Docs dentro de una carpeta y acto seguido lo exporta a otro formato, en este caso subo un PPT y lo convierto en PDF (me hubiese encantado que fuera a HTML pero no acepta esa opción).</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// Datos de login a la API de Google</span>
<span style="color: #3E6D8F;">$clientlogin_url</span> = <span style="color: #ff0000;">"https://www.google.com/accounts/ClientLogin"</span>;
<span style="color: #3E6D8F;">$clientlogin_post</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
    <span style="color: #ff0000;">"accountType"</span> =&gt; <span style="color: #ff0000;">"GOOGLE"</span>,
    <span style="color: #ff0000;">"Email"</span> =&gt; <span style="color: #ff0000;">"miemail@gmail.com"</span>,
    <span style="color: #ff0000;">"Passwd"</span> =&gt; <span style="color: #ff0000;">"mipassword"</span>,
    <span style="color: #ff0000;">"service"</span> =&gt; <span style="color: #ff0000;">"writely"</span>,
    <span style="color: #ff0000;">"source"</span> =&gt; <span style="color: #ff0000;">"WPDOCS"</span>
<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Inicializamos el CURL</span>
<span style="color: #3E6D8F;">$curl</span> = curl_init<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$clientlogin_url</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Obtenemos el string de autenticaci&Atilde;&sup3;n</span>
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POSTFIELDS, <span style="color: #3E6D8F;">$clientlogin_post</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPAUTH, CURLAUTH_ANY<span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_SSL_VERIFYPEER, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_RETURNTRANSFER, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$response</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/Auth=([a-z0-9_<span style="color: #000099; font-weight: bold;">\-</span>]+)/i"</span>, <span style="color: #3E6D8F;">$response</span>, <span style="color: #3E6D8F;">$matches</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$auth</span> = <span style="color: #3E6D8F;">$matches</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Cabeceras de autenticaci&Atilde;&sup3;n</span>
<span style="color: #3E6D8F;">$headers</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
    <span style="color: #ff0000;">"Authorization: GoogleLogin auth="</span> . <span style="color: #3E6D8F;">$auth</span>,
    <span style="color: #ff0000;">"GData-Version: 3.0"</span>,
<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Recuperamos los ficheros y carpetas que tenemos en Google Docs para no crear dos veces la misma carpeta</span>
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_URL, <span style="color: #ff0000;">"http://docs.google.com/feeds/default/private/full?showfolders=true"</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPHEADER, <span style="color: #3E6D8F;">$headers</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$listado</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$nombre_carpeta</span> = <span style="color: #ff0000;">'WPDOCS'</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Si no se ha creado la carpeta, la creamos</span>
<span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$listado</span>, <span style="color: #ff0000;">'&lt;title&gt;'</span>.<span style="color: #3E6D8F;">$nombre_carpeta</span>.<span style="color: #ff0000;">'&lt;/title&gt;'</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// Make the request</span>
  <span style="color: #3E6D8F;">$h</span> = <a href="http://www.php.net/array_merge"><span style="color: #000066;">array_merge</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$headers</span>,<a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-Type: application/atom+xml'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$xml</span> = <span style="color: #ff0000;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;&lt;category scheme=&quot;http://schemas.google.com/g/2005#kind&quot; term=&quot;http://schemas.google.com/docs/2007#folder&quot;/&gt;&lt;title&gt;'</span>.<span style="color: #3E6D8F;">$nombre_carpeta</span>.<span style="color: #ff0000;">'&lt;/title&gt;&lt;/entry&gt;'</span>;
  curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_URL, <span style="color: #ff0000;">"http://docs.google.com/feeds/default/private/full"</span><span style="color: #66cc66;">&#41;</span>;
  curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPHEADER, <span style="color: #3E6D8F;">$h</span><span style="color: #66cc66;">&#41;</span>;
  curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POSTFIELDS, <span style="color: #3E6D8F;">$xml</span><span style="color: #66cc66;">&#41;</span>;
  curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #3E6D8F;">$response</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$response</span> = simplexml_load_string<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$response</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$id_folder</span> = <span style="color: #3E6D8F;">$response</span>-&gt;<span style="color: #006600;">id</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// Recuperamos la ID de la carpeta creada anteriormente</span>
  <a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"#&lt;title&gt;$nombre_carpeta&lt;/title&gt;&lt;content type='application/atom<span style="color: #000099; font-weight: bold;">\+</span>xml;type=feed' src='([^']+)'#"</span>, <span style="color: #3E6D8F;">$listado</span>, <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$id_folder</span> = <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Subimos el PPT</span>
<span style="color: #3E6D8F;">$h</span> = <a href="http://www.php.net/array_merge"><span style="color: #000066;">array_merge</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$headers</span>,<a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-Type: application/vnd.ms-powerpoint'</span>, <span style="color: #ff0000;">'Slug: fichero'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$filepath</span>=<span style="color: #ff0000;">'/path/fichero.ppt'</span>;
<span style="color: #3E6D8F;">$data</span>=<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/fread"><span style="color: #000066;">fread</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$filepath</span>, <span style="color: #ff0000;">"rb"</span><span style="color: #66cc66;">&#41;</span>, <a href="http://www.php.net/filesize"><span style="color: #000066;">filesize</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$filepath</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_URL, <span style="color: #ff0000;">"http://docs.google.com/feeds/default/private/full"</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPHEADER, <span style="color: #3E6D8F;">$h</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POSTFIELDS, <span style="color: #3E6D8F;">$data</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$response</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$response</span> = simplexml_load_string<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$response</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$id_doc</span> = <span style="color: #3E6D8F;">$response</span>-&gt;<span style="color: #006600;">id</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Limpiamos los IDs de los ficheros devueltos por Google, solo nos interesa del %3A para adelante</span>
<a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/%3A(.+)/'</span>, <span style="color: #3E6D8F;">$id_doc</span>, <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$id_doc</span> = <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
<a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/%3A(.+)/'</span>, <span style="color: #3E6D8F;">$id_folder</span>, <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$id_folder</span> = <span style="color: #3E6D8F;">$m</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Lo movemos a la carpeta</span>
<span style="color: #3E6D8F;">$h</span> = <a href="http://www.php.net/array_merge"><span style="color: #000066;">array_merge</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$headers</span>,<a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-Type: application/atom+xml'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$data</span> = <span style="color: #ff0000;">'&lt;?xml version=<span style="color: #000099; font-weight: bold;">\'</span>1.0<span style="color: #000099; font-weight: bold;">\'</span> encoding=<span style="color: #000099; font-weight: bold;">\'</span>UTF-8<span style="color: #000099; font-weight: bold;">\'</span>?&gt;&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;&lt;id&gt;https://docs.google.com/feeds/default/private/full/document%3A'</span>.<span style="color: #3E6D8F;">$id_doc</span>.<span style="color: #ff0000;">'&lt;/id&gt;&lt;/entry&gt;'</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_URL, <span style="color: #ff0000;">"http://docs.google.com/feeds/default/private/full/folder%3A"</span>.<span style="color: #3E6D8F;">$id_folder</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPHEADER, <span style="color: #3E6D8F;">$h</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POSTFIELDS, <span style="color: #3E6D8F;">$data</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$response</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//header('Content-type: text/xml');</span>
<span style="color: #808080; font-style: italic;">//echo $response;</span>
<span style="color: #808080; font-style: italic;">// Parse the response</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Exportamos a HTML</span>
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_URL, <span style="color: #ff0000;">"http://docs.google.com/feeds/download/presentations/Export?docID=$id_doc&amp;exportFormat=pdf"</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_HTTPHEADER, <span style="color: #3E6D8F;">$h</span><span style="color: #66cc66;">&#41;</span>;
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-type: application/pdf'</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$curl</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p>Vía / <a href="http://kovshenin.com/archives/google-docs-api-client-login-with-php-and-curl/">Google Docs API: Client Login with PHP and Curl</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/03/27/subir-y-exportar-documentos-usando-google-docs-y-php.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Librería PHP para Google Buzz</title>
		<link>http://sentidoweb.com/2011/02/01/libreria-php-para-google-buzz.php</link>
		<comments>http://sentidoweb.com/2011/02/01/libreria-php-para-google-buzz.php#comments</comments>
		<pubDate>Tue, 01 Feb 2011 11:09:18 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[buzz]]></category>
		<category><![CDATA[google buzz]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2673</guid>
		<description><![CDATA[La verdad es que no tengo ni idea del éxito/uso de Google Buzz, dicen que es un fracaso, pero claro, a saber lo que es un fracaso comparado con otras redes sociales (no Twitter o Facebook, claro), por lo que no está mal saber que existe una librería y que te permite trabajar con Google [...]]]></description>
			<content:encoded><![CDATA[<p>La verdad es que no tengo ni idea del éxito/uso de Google Buzz, dicen que es un fracaso, pero claro, a saber lo que es un fracaso comparado con otras redes sociales (no Twitter o Facebook, claro), por lo que no está mal saber que existe una librería y que te permite trabajar con Google Buzz.</p>
<pre><code><pre class="php">&nbsp;
<span style="color: #808080; font-style: italic;">// Include the library files</span>
<span style="color: #723b00;">require_once</span> <span style="color: #ff0000;">"google-api-php-client/src/apiClient.php"</span>;
<span style="color: #723b00;">require_once</span> <span style="color: #ff0000;">"google-api-php-client/src/contrib/apiBuzzService.php"</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Create the apiClient and Buzz service classes:</span>
<span style="color: #3E6D8F;">$apiClient</span> = <span style="color: #000000; font-weight: bold;">new</span> apiClient<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$buzz</span> = <span style="color: #000000; font-weight: bold;">new</span> apiBuzzService<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$apiClient</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Add the OAuth authentication flow to your app:</span>
<span style="color: #808080; font-style: italic;">// If a oauth token was stored in the session, use that- and otherwise go through the oauth dance</span>
<a href="http://www.php.net/session_start"><span style="color: #000066;">session_start</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_SESSION</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'auth_token'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #3E6D8F;">$apiClient</span>-&gt;<span style="color: #006600;">setAccessToken</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_SESSION</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'auth_token'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// In a real application this would be stored in a database, and not in the session!</span>
  <span style="color: #3E6D8F;">$_SESSION</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'auth_token'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3E6D8F;">$apiClient</span>-&gt;<span style="color: #006600;">authenticate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Make an API call</span>
<span style="color: #3E6D8F;">$activities</span> = <span style="color: #3E6D8F;">$buzz</span>-&gt;<span style="color: #006600;">listActivities</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'@consumption'</span>, <span style="color: #ff0000;">'@me'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// And echo the returned activities</span>
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;pre&gt;Activities:<span style="color: #000099; font-weight: bold;">\n</span>"</span> . <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$activities</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">"&lt;/pre&gt;"</span>;</pre></code></pre>
<p><a href="http://code.google.com/p/buzz-php-client/">buzz-php-client</a>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/02/01/libreria-php-para-google-buzz.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acortar URLs mediante goo.gl y PHP</title>
		<link>http://sentidoweb.com/2011/01/18/acortar-urls-mediante-goo-gl-y-php.php</link>
		<comments>http://sentidoweb.com/2011/01/18/acortar-urls-mediante-goo-gl-y-php.php#comments</comments>
		<pubDate>Tue, 18 Jan 2011 10:02:14 +0000</pubDate>
		<dc:creator>displaynone</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[acortador]]></category>
		<category><![CDATA[goo.gl]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://sentidoweb.com/?p=2670</guid>
		<description><![CDATA[La API de Google para acortar URLs permite acortar URLs, recuperar info del link original y las URLs acortadas de un usuario, aunque para usarlo se necesita crear una clave y dar de alta proyecto. El resto es fácil, acceso mediante CURL y listo: define&#40;'GOOGLE_API_KEY', '[insert your key here]'&#41;; define&#40;'GOOGLE_ENDPOINT', 'https://www.googleapis.com/urlshortener/v1'&#41;; function shortenUrl&#40;$longUrl&#41; &#123; // [...]]]></description>
			<content:encoded><![CDATA[<p>La <a href="http://code.google.com/apis/urlshortener/index.html">API de Google para acortar URLs</a> permite acortar URLs, recuperar info del link original y las URLs acortadas de un usuario, aunque para usarlo se necesita crear una clave y dar de alta proyecto.</p>
<p>El resto es fácil, acceso mediante CURL y listo:</p>
<pre><code><pre class="php">    <a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'GOOGLE_API_KEY'</span>, <span style="color: #ff0000;">'[insert your key here]'</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'GOOGLE_ENDPOINT'</span>, <span style="color: #ff0000;">'https://www.googleapis.com/urlshortener/v1'</span><span style="color: #66cc66;">&#41;</span>;
 
    <span style="color: #000000; font-weight: bold;">function</span> shortenUrl<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$longUrl</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// initialize the cURL connection</span>
        <span style="color: #3E6D8F;">$ch</span> = curl_init<span style="color: #66cc66;">&#40;</span>
            <a href="http://www.php.net/sprintf"><span style="color: #000066;">sprintf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'%s/url?key=%s'</span>, GOOGLE_ENDPOINT, GOOGLE_API_KEY<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// tell cURL to return the data rather than outputting it</span>
        curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span>, CURLOPT_RETURNTRANSFER, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// create the data to be encoded into JSON</span>
        <span style="color: #3E6D8F;">$requestData</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
            <span style="color: #ff0000;">'longUrl'</span> =&gt; <span style="color: #3E6D8F;">$longUrl</span>
        <span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// change the request type to POST</span>
        curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// set the form content type for JSON data</span>
        curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span>, CURLOPT_HTTPHEADER, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-type: application/json'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// set the post body to encoded JSON data</span>
        curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span>, CURLOPT_POSTFIELDS, json_encode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$requestData</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// perform the request</span>
        <span style="color: #3E6D8F;">$result</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span><span style="color: #66cc66;">&#41;</span>;
        curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$ch</span><span style="color: #66cc66;">&#41;</span>;
 
        <span style="color: #808080; font-style: italic;">// decode and return the JSON response</span>
        <span style="color: #723b00;">return</span> json_decode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$result</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
 
    <span style="color: #3E6D8F;">$response</span> = shortenUrl<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://phpriot.com'</span><span style="color: #66cc66;">&#41;</span>;
 
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a href="http://www.php.net/sprintf"><span style="color: #000066;">sprintf</span></a><span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'%s was shortened to %s'</span>,
        <span style="color: #3E6D8F;">$response</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'longUrl'</span><span style="color: #66cc66;">&#93;</span>,
        <span style="color: #3E6D8F;">$response</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#93;</span>
    <span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p><a href="http://www.phpriot.com/articles/google-url-shorening-api">Shortening URLs for goo.gl with Google&#8217;s URL Shortener API</a></p>
<p>Vía / <a href="http://www.phpdeveloper.org/news/15726">PHPDeveloper.org</a></p>]]></content:encoded>
			<wfw:commentRss>http://sentidoweb.com/2011/01/18/acortar-urls-mediante-goo-gl-y-php.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

