under /usr/share/php/tweeper and then make a symlink to the wrapper script
"tweeper" under /usr/bin
-Tweeper depends on php-xml-serializer which is used to convert json to xml for
-some sites that provide the timeline data in json rather than in usable html.
+Tweeper depends on php-symfony-serializer which is used to convert json to xml
+for some sites which provide the timeline data in json rather than in usable
+html.
+News for v0.5:
+==============
+
+ * Use the Symfony Serializer component instead of the PEAR XML_Serializer
+ * Make the Twitter stylesheet stricter to avoid empty timeline entries
+
News for v0.4:
==============
<xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(text()))"/>
</xsl:template>
- <xsl:variable name="user-name" select="//ProfilePage/XML_Serializer_Tag/user/username"/>
+ <xsl:variable name="user-name" select="//ProfilePage/user/username"/>
<!-- Some users do not specify the full name -->
- <xsl:variable name="full-name" select="//ProfilePage/XML_Serializer_Tag/user/full_name"/>
+ <xsl:variable name="full-name" select="//ProfilePage/user/full_name"/>
<xsl:variable name="screen-name">
<xsl:choose>
<xsl:when test="$full-name != ''">
</xsl:choose>
</xsl:variable>
- <xsl:template match="//media/nodes/XML_Serializer_Tag">
+ <xsl:template match="//media/nodes">
<xsl:variable name="item-content-image" select="./display_src"/>
<xsl:variable name="item-content-caption" select="./caption"/>
<xsl:variable name="item-permalink" select="concat($BaseURL, '/p/', ./code, '/')"/>
<xsl:value-of select="//user/profile_pic_url"/>
</url>
</image>
- <xsl:apply-templates select="//media/nodes/XML_Serializer_Tag"/>
+ <xsl:apply-templates select="//media/nodes"/>
</channel>
</rss>
</xsl:template>
<xsl:variable name="screen-name" select="//div[@class='user-actions btn-group not-following ']/@data-screen-name"/>
- <xsl:template match="//li[@data-item-type='tweet']">
+ <xsl:template match="//li[@data-item-id and @data-item-type='tweet']">
<xsl:variable name="user-name" select=".//div[contains(@class, 'js-stream-tweet')]/@data-screen-name"/>
<xsl:variable name="item-content" select=".//p[contains(@class, 'js-tweet-text')]"/>
<xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
</xsl:template>
<xsl:template match="/">
- <xsl:variable name="channel-title" select="concat('Twitter / ', $screen-name)"/>
+ <xsl:variable name="channel-title">
+ <xsl:choose>
+ <xsl:when test="$screen-name != ''">
+ <xsl:value-of select="concat('Twitter / ', $screen-name)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('Twitter / ', normalize-space(//h1[1]))"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<xsl:variable name="channel-link" select="//link[@rel='canonical']/@href"/>
<rss version="2.0">
<xsl:value-of select="//a[contains(@class, 'profile-picture media-thumbnail')]/@href"/>
</url>
</image>
- <xsl:apply-templates select="//li[@data-item-type='tweet']"/>
+ <xsl:apply-templates select="//ol[@id='stream-items-id']/li[@data-item-id and @data-item-type='tweet']"/>
</channel>
</rss>
</xsl:template>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-require_once 'XML/Serializer.php';
+require_once 'Symfony/Component/Serializer/autoload.php';
+
+use Symfony\Component\Serializer\Serializer;
+use Symfony\Component\Serializer\Encoder\XmlEncoder;
+use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
date_default_timezone_set('UTC');
return NULL;
}
- $data = json_decode($matches[1]);
+ // Apparenty the ObjectNormalizer used afterwards is not able to handle
+ // the stdClass object created by json_decode() with the default setting
+ // $assoc = false; so use $assoc = true
+ $data = json_decode($matches[1], $assoc = true);
if (!$data) {
return NULL;
}
+ $encoder = new XmlEncoder();
+ $normalizer = new ObjectNormalizer();
+ $serializer = new Serializer(array($normalizer), array($encoder));
+
$serializer_options = array (
- 'addDecl' => TRUE,
- 'encoding' => "UTF-8",
- 'indent' => ' ',
- 'rootName' => $rootName,
+ 'xml_encoding' => "UTF-8",
+ 'xml_format_output' => TRUE,
+ 'xml_root_node_name' => $rootName,
);
- $serializer = new XML_Serializer($serializer_options);
-
- $status = $serializer->serialize($data);
- if (PEAR::isError($status)) {
- trigger_error($status->getMessage(), E_USER_ERROR);
+ $xml_data = $serializer->serialize($data, 'xml', $serializer_options);
+ if (!$xml_data) {
+ trigger_error("Cannot serialize data", E_USER_ERROR);
return NULL;
}
- return $serializer->getSerializedData();
+ return $xml_data;
}
private function get_xml_instagram_com($html) {