duanshan3065 2015-11-04 23:38
浏览 50

我试图使用Soda API显示来自Socrata的一些数据并得到以下消息**来自服务器的错误“0”:**

I am trying to display some data from Socrata using Soda API and got the following message

Error "0" from server:

What does this mean?

This is my code:

 $socrata = new Socrata("https://data.medicare.gov", $app_token);
 $params = array("\$where" => "starts_with(zip, $model->zipcode)");
 $response = $socrata->get("/resource/aeay-dfax.json",$params);
 ?> 
 <?= Html::encode($model->zipcode) ?>

 <h2>Results</h2>

  <?# Create a table for our actual data ?>
  <table border="1">
    <tr>
      <th>Last Name</th>
      <th>First Name</th>
    </tr>
    <?# Print rows ?>
    <?php foreach($response as $row) { ?>
      <tr>
        <td><?= $row["lst_nm"] ?></td>
        <td><?= $row["fst_nm"] ?></td>
      </tr>
    <?php } ?>
  </table>

  <h3>Raw Response</h3>
  <pre><?= var_dump($response) ?></pre>
  • 写回答

1条回答 默认 最新

  • duankuang7928 2015-11-06 04:24
    关注

    The reason you are getting an error from Socrata is because of a type mismatch between your query and the available data. The zip column is treated as plain text so you must give it a string in your SoQL query as well. Simply wrap $model->zipcode in escaped quotes like so:

    $params = array("\$where" => "starts_with(zip, \"$model->zipcode\")");
    

    Otherwise, you'd be giving the query an integer. You could also use single quotes if you don't want to escape the double quotes.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作