gpt4 book ai didi

PrestaShop 创建客户

转载 作者:行者123 更新时间:2023-12-03 17:53:08 24 4
gpt4 key购买 nike

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

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 是
<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>

我得到的回应是
<?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>

最佳答案

“客户”不是一个独立的字段,而是所有其他字段(如名字、姓氏、电子邮件等)的容器。

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

关于PrestaShop 创建客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15924253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com