首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发票快递API 500错误

发票快递API 500错误
EN

Stack Overflow用户
提问于 2013-12-17 04:50:59
回答 1查看 409关注 0票数 1

我正在尝试使用快速发票api在我的帐户上创建新的发票,但由于该api调用,它一直抛出500错误。

我的代码是:

代码语言:javascript
复制
    <?php
include_once('../libraries/spyc.php');
$APP_CONFIG = spyc_load_file('../libraries/config.yaml');

$screenname = $APP_CONFIG['screen_name'];
$api_key = $APP_CONFIG['api_key'];
$host = $APP_CONFIG['host'];

ob_start(); 
$db = new mysqli('localhost', 'user' , 'pass', 'db');
$id = $_GET['id'];
$result = mysqli_query($db,"SELECT * FROM orders WHERE id = '".$id."'");
$value = mysqli_fetch_assoc($result);

$date = date("d/m/Y", strtotime($value['post_date']));


$invoice_data = '
  <?xml version="1.0" encoding="UTF-8"?>
  <invoice>
   <date>' . $date . '<date>
   <due_date>' . $date . '</due_date>
   <reference>25381g</reference>
   <observations>0</observations>
   <retention>0</retention>
   <client>
    <name>XX Bruce Norris</name>
    <email>foo@ar.com</email>
    <address>Badgad</address>
    <postal_code>120213920139</postal_code>
    <country>Germany</country>
    <fiscal_id>12</fiscal_id>
    <website> h</website>
    <phone>2313423424</phone>
    <fax>0</fax>
    <observations> 0</observations>
   </client>
   <items type="array">
    <item>
     <name>Product 1</name>
     <description>Cleaning product</description>
     <unit_price>10.0</unit_price>
     <quantity>1.0</quantity>
     <unit>unit</unit>
      <tax>
        <name>IVA23</name>
      </tax>
     <discount>10.0</discount>
    </item>
   </items>
  </invoice>';



$endpoint = "https://".$screenname.".".$host."/invoices.xml?api_key=".$api_key;


// Initialize handle and set options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $invoice_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));

// Execute the request
$result_invoice = curl_exec($ch);
// Close the handle
curl_close($ch);

echo $result_invoice;

我知道这不是数据库访问的问题,因为我已经测试过它和查询本身,它返回得很好。

我还尝试将错误报告设置为E_ALL并显示错误,但在网页上仍然只能得到500个错误。

EN

回答 1

Stack Overflow用户

发布于 2014-11-19 18:07:52

我遇到了同样的500错误,然后我意识到,我的错误在URL中。https://screen-name.invoicexpress.net/invoices.xml

然后,我碰巧通过http://invoicexpress.com/api/users/login访问,它会返回URL的“屏幕名称”部分。

确保$screenname是你的,它可以帮助我摆脱500错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20620649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档