The Trap of Web Design

NP_Moblog の改造続き

iPhone の Mail (Mac の Mail も)でモブログすると、本文→添付画像という内容だと本文が消えちゃいます。その対処。


function _decodeMultiPart($parts, &$texts, &$fileNames)

case 'text':
$this->_info(__LINE__ . ": text part をみつけました[{$part->ctype_primary}/{$part->ctype_secondary}]");
$texts[$part->ctype_secondary] = $this->_textPart($part);
break;

のところを以下に。

case 'text':
$this->_info(__LINE__ . ": text part をみつけました[{$part->ctype_primary}/{$part->ctype_secondary}]");
//$texts[$part->ctype_secondary] = $this->_textPart($part);
if( $text = $this->_textPart($part) )
	$texts[$part->ctype_secondary][] = $text;
break;

でもって、function addItemByMail($userId, $msg) 内の

// body
$text = "";
if( strtolower($decodedMsg->ctype_primary) == "text" ){
	$this->_info(__LINE__ . ": single partメッセージです");
	$text = $this->_textPart($decodedMsg);
} elseif ( strtolower($decodedMsg->ctype_primary) == "multipart" ){
	$this->_info(__LINE__ . ": multipart partメッセージです");
	$texts = Array();
	$fileNames = Array();
	$this->_decodeMultiPart($decodedMsg->parts, $texts, $fileNames);
	$text = $texts['plain'];
	if( $texts['html'] ) $text = $texts['html'];
}

のところを以下に。

// body
$text = "";
if( strtolower($decodedMsg->ctype_primary) == "text" ){
	$this->_info(__LINE__ . ": single partメッセージです");
	$text = $this->_textPart($decodedMsg);
} elseif ( strtolower($decodedMsg->ctype_primary) == "multipart" ){
	$this->_info(__LINE__ . ": multipart partメッセージです");
	$texts = Array();
	$fileNames = Array();
	$this->_decodeMultiPart($decodedMsg->parts, $texts, $fileNames);
	//$text = $texts['plain'];
	foreach ($texts['plain'] as $val) {
		$text .= trim($val)."\n\n";
	}
	if( $texts['html'] ) $text = $texts['html'];
}

プログラム解析して、メールを80通くらい実際に出して取得してのチェックをした上で、いままさに、Makeup Tour で使ってもらってます。iPhone でオッケーですけど、他のメールソフト、携帯とかでどうなのかを逆にチェックしてません。複数画像添付でも大丈夫らしい。

ホントは、Mail で例えば「テキスト→画像→テキスト→画像」にしたら、そのまま投稿されるのがいいんですが、そーするには NP_Moblog のテンプレートの仕組みまで変えなくちゃならないので、さすがにもう自分にゃ無理っす。

そういや普通の携帯メールで、複数画像投稿する方は結構いたんですが、どうやってたんだか、もう忘れました。ちなみに、iPhone の画像添付メールで、画像を複数添付するのはできなくはないですが、非常に手間です。簡単なやり方を知ってる方がいたら教えてください。

2010-11-14 17:10 | Nucleus | ichiro | permalink


Comments

コメントはまだありません


Portfolio

Stagemind

▲ 珍しくカバーアニメーションとか