media:thumbnail url=”hoge”は、以下で取得します。
$value->children(‘media’, true)->thumbnail->attributes()->url;
$rss = simplexml_load_file('https://jp.techcrunch.com/feed/'); $i = 0; foreach($rss->channel->item as $value){ $url = $value->children('media', true)->thumbnail->attributes()->url; $data = file_get_contents($url); $pass = "img/tech".$i.".jpg"; file_put_contents($pass, $data); $i++; } mb_language("Japanese"); mb_internal_encoding("UTF-8"); $to = "notwatch@gmail.com"; $date = date("m月d日"); $subject = "今日のTech Chrunch (" . $date.")"; $filepath = "img/tech0.jpg"; $mime_type = "application/octet-stream"; $boundary = "__BOUNDARY__"; $additional_headers = "Content-Type: multipart/mixed;boundary=\"".$boundary."\"\n"; $message = "--" . $boundary . "\n"; $message .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n"; foreach($rss->channel->item as $value){ $message .= $value->title ."\n"; $message .= $value->link . "\n"; } $message .="--" . $boundary . "\n"; $message .="Content-Type:". $mime_type . "; name=\"" .basename($filepath) . "\"\n"; $message .="Content-Disposition: attachment; filename=\"" .basename($filepath) ."\"\n"; $message .="Content-Transfer-Encoding: base64\n"; $message .= "\n"; $message .= chunk_split(base64_encode(file_get_contents($filepath)))."\n"; $message .="--" . $boundary . "--"; mb_send_mail($to, $subject, $message, $additional_headers);
お、まぁまぁいいやんけ!
写真複数いきたいですね。