craigslist批量通过HTML表单提供无法解析RSS错误

时间:2013-06-14 11:14:24

标签: php api curl html-form html-form-post

我试图在Craigslist上发布他们的批量数据提取方法。

为此,我使用以下代码:

<form method="POST" action="https://post.craigslist.org/bulk-rss/post" enctype="text/xml">
    <input name="add" type="submit" value="Create"  />
    <input type="hidden" name="data" value='<?php echo '<?xml version="1.0"?>
    <rdf:RDF xmlns="http://purl.org/rss/1.0/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:cl="http://www.craigslist.org/about/cl-bulk-ns/1.0">

      <channel>
        <items>
          <rdf:li rdf:resource="NYCBrokerHousingSample1"/>
          <rdf:li rdf:resource="NYCBrokerHousingSample2"/>
        </items>

        <cl:auth username="user@demo.com"
                 password="demo123"
                 accountID="0"/>
      </channel>

      <item rdf:about="NYCBrokerHousingSample1">
        <cl:category>fee</cl:category>
        <cl:area>nyc</cl:area>
        <cl:subarea>mnh</cl:subarea>
        <cl:neighborhood>Upper West Side</cl:neighborhood>
        <cl:housingInfo price="1450"
                        bedrooms="0"
                        sqft="600"/>
        <cl:replyEmail privacy="C">bulkuser@bulkposterz.net</cl:replyEmail>
        <cl:brokerInfo companyName="Joe Sample and Associates"
                       feeDisclosure="fee disclosure here" />
        <title>Spacious Sunny Studio in Upper West Side</title>
        <description><![CDATA[
          posting body here
        ]]></description>
      </item>

      <item rdf:about="NYCBrokerHousingSample2">
        <cl:category>fee</cl:category>
        <cl:area>nyc</cl:area>
        <cl:subarea>mnh</cl:subarea>
        <cl:neighborhood>Chelsea</cl:neighborhood>
        <cl:housingInfo price="2175"
                        bedrooms="1"
                        sqft="850"
                        catsOK="1"/>
        <cl:mapLocation city="New York"
                        state="NY"
                        crossStreet1="23rd Street"
                        crossStreet2="9th Avenue"/>
        <cl:replyEmail privacy="C" 
                       otherContactInfo="212.555.1212">
          bulkuser@bulkposterz.net
        </cl:replyEmail>
        <cl:brokerInfo companyName="Joe Sample and Associates"
                       feeDisclosure="fee disclosure here" />
        <title>1BR Charmer in Chelsea</title>
        <description><![CDATA[
          posting body goes here
        ]]></description>
        <cl:PONumber>Purchase Order 094122</cl:PONumber>
      </item>
    </rdf:RDF>' ?>'>
    </form> 

当我按下创建按钮时,它会发布数据以形成动作网址

和givin跟随错误:

  

无法解析RSS:第1行第3列第3行格式不正确(无效令牌)

我想知道我是否以正确的方式做到了?

如果是,请帮助我解决错误,

如果没有建议我的另一种方式

  

此处是创建帐户的链接:https://accounts.craigslist.org/

我想提到的另一件事我也尝试过卷曲方式,如此问题的答案所示 Craigslist Automated Posting API?请参阅(krauses)的回答。

它在浏览器中显示以下结果而不发布任何内容:

Array (
    [url] => https://post.craigslist.org/bulk-rss/post
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 1.781
    [namelookup_time] => 1.438
    [connect_time] => 1.797
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] =>  ).

1 个答案:

答案 0 :(得分:0)

第一行应该是XML声明。

 <?xml version="1.0"?>

编辑:每http://www.craigslist.org/about/bulk_posting_interface#submission_format