Laravel RSS Feed img未经过验证

时间:2018-02-15 05:22:57

标签: image rss laravel-5.2

大家好,我需要你的帮助,

我有这个RSS订阅源视图,当我尝试在http://www.feedvalidator.org/check.cgi?url=http%3A%2F%2Fwizardform.yourmartialarts.school%2Fnextgrading上验证它时,我收到了此错误。

  

第6行,第8列:未定义的通道元素:img [help]

     

第20行,第7列:XML解析错误:: 20:7:不匹配的标记[help]

<img src="{{ utf8_decode(url('/getNextGrading') . '/' . $user->id) }}" style="width: 500px;" alt="image"/>

这是代码

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> 
<channel>
<title>Next Grading</title> 
@if($users->count() > 0)
    @foreach($users as $user) 
        <img src="{{ utf8_decode(url('/getNextGrading') . '/' . $user->id) }}" style="width: 500px;" alt="image"/>     
        <item>         
        <title>Next Grading</title> 
        <description>
        {{-- {{$user->name . ' ' .$user->organization_id . ' ' . $user->id}} <hr> --}}
        </description>
        <guid isPermaLink="false"></guid> 
        <media:content url="{{ url('/getNextGrading') . '/' . $user->id }}" fileSize="2471632" type="picture/jpg" height="240" width="320" duration="147" medium="video" isDefault="true"> 
        <media:thumbnail url="http://www.webmonkey.com/images/monkeyrock-thumb.jpg" height="98" width="145"></media:thumbnail>
        </media:content> 
        <media:content duration="180" medium="video" isDefault="true">
        <media:player url="http://www.somevideouploadsite/webmonkey.html"></media:player> 
        <media:thumbnail url="http://www.webmonkey.com/images/both-thumb.jpg" height="98" width="145"></media:thumbnail> 
        </media:content> 
        </item>         
    @endforeach
@else
    <item> 
        <title>No Birthdays</title> 
        <!-- <guid isPermaLink="false"></guid>  -->
        <media:content url="{{ asset('assets/images/bdays/nobday.jpg') }}" fileSize="2471632" type="picture/jpg" height="240" width="320" duration="147" medium="video" isDefault="true">  
        <media:thumbnail url="http://www.webmonkey.com/images/monkeyrock-thumb.jpg" height="98" width="145"></media:thumbnail>
        </media:content> 
        <media:content duration="180" medium="video" isDefault="true">
        <media:player url="http://www.somevideouploadsite/webmonkey.html"></media:player> 
        <media:thumbnail url="http://www.webmonkey.com/images/both-thumb.jpg" height="98" width="145"></media:thumbnail> 
        </media:content> 
    </item> 
@endif
 </channel> 
 </rss>

1 个答案:

答案 0 :(得分:0)

RSS 2.0为<image>定义了<channel>子元素,而不是<img>

<url><title><link>子元素是必需的,而<width>和子元素是可选的。

<image>
  <url>{{ utf8_decode(url('/getNextGrading') . '/' . $user->id) }}</url>
  <title>Next Grading</title>
  <link>{{ utf8_decode(url('/getNextGrading') . '/' . $user->id) }}</link>
  <width>144</width> <!--Maximum value is 144-->
</image>

参考

http://www.feedvalidator.org/docs/rss2.html