首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >PrestaShop创建客户

PrestaShop创建客户
EN

Stack Overflow用户
提问于 2013-04-10 19:12:50
回答 2查看 3.5K关注 0票数 5

我有这个代码,我试图创建一个新的客户在我的网站上使用prestashop模式。但我在响应中不断收到错误

代码语言:javascript
运行
复制
NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"Login" ofType:@"xml"];

    NSString *xmlStr = [[NSString alloc] initWithContentsOfFile:xmlPath encoding:NSUTF8StringEncoding error:nil];

     NSString *encodedurlstring = (__bridge NSString*) CFURLCreateStringByAddingPercentEscapes (NULL, (__bridge CFStringRef) xmlStr, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8);

    NSString *urlStr = [NSString stringWithFormat:@"http://passkey:@farma-web.it/api/customers/?Xml=%@",encodedurlstring];

    NSURL *webURL = [NSURL URLWithString:urlStr];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:webURL];

    [request setHTTPMethod:@"POST"];
    [request setValue: @"text/xml" forHTTPHeaderField: @"Content-Type"];


    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *response = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

    NSLog(@"response - %@",response);

我附加的XML是

代码语言:javascript
运行
复制
<prestashop>

<customers>

<customer>**I DO NOT KNOW WHAT TO WRITE HERE**</customer>

<email>abc@abc.com</email>

<passwd>12344321</passwd>

<firstname>ABC</firstname>

<lastname>DEF</lastname>

</customers>

</prestashop>

我得到的回应是

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
</errors>
</prestashop>
EN

回答 2

Stack Overflow用户

发布于 2013-08-21 15:11:50

"customer“不是一个独立的字段,而是所有其他字段的容器,比如名字、姓氏、电子邮件等等。

创建客户的最好方法是检索和空白工作表,并用您的数据填充它:http://your-prestashop.com/api/customers?schema=blank

票数 0
EN

Stack Overflow用户

发布于 2014-09-15 09:24:13

我遇到了类似的问题,下面是我在prestashop版本1.6.0.9上发现的:

1)正如@adrien-g指出的,从define('_PS_MODE_DEV_', false);更改为define('_PS_MODE_DEV_',true);http://doc.prestashop.com/display/PS16/Setting+Up+Your+Local+Development+Environment#SettingUpYourLocalDevelopmentEnvironment-Displayingerrormessages

2)接下来,您将开始看到更多有意义的错误,如使用CURL命令模拟的错误:

代码语言:javascript
运行
复制
$ curl -kv https://myprestashop.bitnamiapp.com/prestashop/api/customers?ws_key=secret -d '
<?xml version="1.0" encoding="UTF-8"?><customer><lastname>blue</lastname><firstname>boy</firstname><email>boy@blue.com</email></customer>'
... 
<message><![CDATA[parameter "passwd" required]]></message>
...

3)然后一些实验,比如添加passwdprestashop标签,最终会引导你走上一条成功创建客户的道路:

代码语言:javascript
运行
复制
$ curl -kv https://myprestashop.bitnamiapp.com/prestashop/api/customers?ws_key=secret -d '
<?xml version="1.0" encoding="UTF-8"?>
  <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <customer><lastname>blue</lastname><firstname>boy</firstname><email>boy@blue.com</email>
      <passwd>mysecret</passwd>
    </customer>
  </prestashop>'
... 
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customer><id><![CDATA[3]]></id>...</customer></prestashop>
...

值得注意的是:

使用<?xml ...><prestashop></prestashop>xml=<?xml ...><prestashop></prestashop>

  • 对我使用的版本没有任何影响。使用<prestashop><prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  • 对我使用的版本没有任何影响。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15924253

复制
相关文章

相似问题

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