bloglinesの未読をhtmlメールで送る

 昨日の続き。phpでいじってみた。

<?php

require_once 'Bloglines.php';

$username = 'nanchara@nanchara.or.jp';
$password = 'nanchara';

$address = "nanchara@nanchara.co.jp";

$bloglines = new Bloglines($username, $password);
$count = $bloglines->notify();
$subs = $bloglines->listSubs();

ob_start();

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="bloglines.css" type="text/css" />
<title>My Bloglines</title>
</head>
<body>

中間部分は省略。


</body>
</html>

<?php
$text=ob_get_contents();
$text=mb_convert_encoding($text,"ISO-2022-JP","UTF-8");
mb_send_mail($address,"bliglines new entries",$text,"Content-Type: text/html; charset=ISO-2022-JP");
ob_end_clean();

?>

 antipop - PHP5 で Bloglines Web Services をあれこれしてみるをそのまま利用して、前後にちょっと書き足した程度。最初「そんなクラスあらへんで」とエラーがでていて悩んだが原因発見。このスクリプトのファイル名をbloglines.phpとしていたので、ライブラリのbloglines.phpを読み込まずに自分自身を読み込んでいたせいだった。ファイル名を変更して解決。
 文字化けもあったけど、いろいろと文字コードの設定を変えてみて課題クリア。普通に表示されているけど「charset=utf-8」ってのは内部矛盾していそう。
 最初htmlメールの送り方がわからんかったけど、メーラのデータファイルを直接覗いて「content="text/plain」を「content="text/html」に変更すればいいとわかった。