Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
#prestashop api更新错误:未发送id_Api_Prestashop - Fatal编程技术网

#prestashop api更新错误:未发送id

#prestashop api更新错误:未发送id,api,prestashop,Api,Prestashop,我用过这个密码,一直说没有发送id。。调试模式打开。来自服务器的响应也在下面。有什么想法吗 只是在挖掘客户的最新信息。简单过滤器: $filter = array( 'email' => "banana@sapo.pt" ); $opt = array( 'resource' => 'customers', 'display' => 'full', 'filter' => $filter ); 获取信息: $xml = $this-&g

我用过这个密码,一直说没有发送id。。调试模式打开。来自服务器的响应也在下面。有什么想法吗

只是在挖掘客户的最新信息。简单过滤器:

$filter = array(
    'email' => "banana@sapo.pt"
);

$opt = array(
    'resource' => 'customers',
    'display' => 'full',
    'filter' => $filter
);
获取信息:

$xml = $this->webService->get($opt);

$resources = $xml->children()->children();

$customer_id = $resources->customer->id;
dump($customer_id);

$resources->customer->email = "banana1@sapo.pt";
尝试使用一封简单的新电子邮件进行更新,传递收到的id:

try {
    $opt = array('resource' => 'customers');
    $opt['putXml'] = $xml->children()->asXML();
    $opt['id'] = $customer_id;
    dump($opt);
    $xml = $this->webService->edit($opt);

} catch (PrestaShopWebserviceException $ex) {
    // Here we are dealing with errors
    $trace = $ex->getTrace();
    if ($trace[0]['args'][0] == 404) echo 'Bad ID';
    else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
    else echo 'Other error<br />' . $ex->getMessage();
}
试试看{
$opt=array('resource'=>'customers');
$opt['putXml']=$xml->children()->asXML();
$opt['id']=$customer\u id;
转储(可选);
$xml=$this->webService->edit($opt);
}捕获(PrestaShopWebserviceException$ex){
//这里我们处理的是错误
$trace=$ex->getTrace();
如果($trace[0]['args'][0]==404)回显'Bad ID';
else if($trace[0]['args'][0]==401)回显'Bad auth key';
else回显“其他错误
”。$ex->getMessage(); }
调试打开时发送的XML:此信息来自浏览器

    <?xml version="1.0" encoding="UTF-8"?>
    <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <customers>
    <customer>
        <id>1</id>
        <id_default_group xlink:href="http://prestashop.bicimax.pt/api/groups/3">3</id_default_group>
        <id_lang xlink:href="http://prestashop.bicimax.pt/api/languages/1">1</id_lang>
        <newsletter_date_add>2017-06-13 23:25:36</newsletter_date_add>
        <ip_registration_newsletter/>
        <last_passwd_gen>2017-06-13 17:15:10</last_passwd_gen>
        <secure_key>b4a1c9fb21b756161ed5ae70e9266750</secure_key>
        <deleted>0</deleted>
        <passwd>86e2c0367d56229fcafeb04913e3cd3d</passwd>
        <lastname>cunha</lastname>
        <firstname>pedro</firstname>
        <email>banana1@sapo.pt</email>
        <id_gender>0</id_gender>
        <birthday>0000-00-00</birthday>
        <newsletter>1</newsletter>
        <optin>1</optin>
        <website/>
        <company/>
        <siret/>
        <ape/>
        <outstanding_allow_amount>0.000000</outstanding_allow_amount>
        <show_public_prices>0</show_public_prices>
        <id_risk>0</id_risk>
        <max_payment_days>0</max_payment_days>
        <active>1</active>
        <note/>
        <is_guest>0</is_guest>
        <id_shop>1</id_shop>
        <id_shop_group>1</id_shop_group>
        <date_add>2017-06-13 23:15:10</date_add>
        <date_upd>2017-06-13 23:25:36</date_upd>
    <associations>
    <groups nodeType="group" api="groups">
        <group xlink:href="http://prestashop.bicimax.pt/api/groups/1">
        <id>1</id>
        </group>
        <group xlink:href="http://prestashop.bicimax.pt/api/groups/2">
        <id>2</id>
        </group>
        <group xlink:href="http://prestashop.bicimax.pt/api/groups/3">
        <id>3</id>
        </group>
    </groups>
    </associations>
    </customer>
    </customers>
    </prestashop>

1.
3.
1.
2017-06-13 23:25:36
2017-06-13 17:15:10
b4a1c9fb21b756161ed5ae70e9266750
0
86e2c0367d56229fcafeb04913e3cd3d
库尼亚
佩德罗
banana1@sapo.pt
0
0000-00-00
1.
1.
0
0
0
0
1.
0
1.
1.
2017-06-13 23:15:10
2017-06-13 23:25:36
1.
2.
3.
已发送XML的变量转储::

[  "resource" => "customers"
  "putXml" => """
    <?xml version="1.0" encoding="UTF-8"?>\n
    <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">\n
    <customers>\n
    <customer>\n
    \t<id>1</id>\n
    \t<id_default_group xlink:href="http://prestashop.bicimax.pt/api/groups/3">3</id_default_group>\n
    \t<id_lang xlink:href="http://prestashop.bicimax.pt/api/languages/1">1</id_lang>\n
    \t<newsletter_date_add>2017-06-13 23:25:36</newsletter_date_add>\n
    \t<ip_registration_newsletter/>\n
    \t<last_passwd_gen>2017-06-13 17:15:10</last_passwd_gen>\n
    \t<secure_key>b4a1c9fb21b756161ed5ae70e9266750</secure_key>\n
    \t<deleted>0</deleted>\n
    \t<passwd>86e2c0367d56229fcafeb04913e3cd3d</passwd>\n
    \t<lastname>cunha</lastname>\n
    \t<firstname>pedro</firstname>\n
    \t<email>banana1@sapo.pt</email>\n
    \t<id_gender>0</id_gender>\n
    \t<birthday>0000-00-00</birthday>\n
    \t<newsletter>1</newsletter>\n
    \t<optin>1</optin>\n
    \t<website/>\n
    \t<company/>\n
    \t<siret/>\n
    \t<ape/>\n
    \t<outstanding_allow_amount>0.000000</outstanding_allow_amount>\n
    \t<show_public_prices>0</show_public_prices>\n
    \t<id_risk>0</id_risk>\n
    \t<max_payment_days>0</max_payment_days>\n
    \t<active>1</active>\n
    \t<note/>\n
    \t<is_guest>0</is_guest>\n
    \t<id_shop>1</id_shop>\n
    \t<id_shop_group>1</id_shop_group>\n
    \t<date_add>2017-06-13 23:15:10</date_add>\n
    \t<date_upd>2017-06-13 23:25:36</date_upd>\n
    <associations>\n
    <groups nodeType="group" api="groups">\n
    \t<group xlink:href="http://prestashop.bicimax.pt/api/groups/1">\n
    \t<id>1</id>\n
    \t</group>\n
    \t<group xlink:href="http://prestashop.bicimax.pt/api/groups/2">\n
    \t<id>2</id>\n
    \t</group>\n
    \t<group xlink:href="http://prestashop.bicimax.pt/api/groups/3">\n
    \t<id>3</id>\n
    \t</group>\n
    </groups>\n
    </associations>\n
    </customer>\n
    </customers>\n
    </prestashop>\n
    """
  "id" => "1"
]
[“资源”=>“客户”
“putXml”=>“”
\n
\n
\n
\n
\t1\n
\t3\n
\t1\n
\t2017-06-13 23:25:36\n
\t\n
\t2017-06-13 17:15:10\n
\tb4a1c9fb21b756161ed5ae70e9266750\n
\t0\n
\t86e2c0367d56229fcafeb04913e3cd3d\n
\tcunha\n
\tpedro\n
\tbanana1@sapo.pt\n
\t0\n
\t0000-00-00\n
\t1\n
\t1\n
\t\n
\t\n
\t\n
\t\n
\t0.000000\n
\t0\n
\t0\n
\t0\n
\t1\n
\t\n
\t0\n
\t1\n
\t1\n
\t2017-06-13 23:15:10\n
\t2017-06-13 23:25:36\n
\n
\n
\t\n
\t1\n
\t\n
\t\n
\t2\n
\t\n
\t\n
\t3\n
\t\n
\n
\n
\n
\n
\n
"""
“id”=>“1”
]

当您在$opt数组中使用'display'=>'full'时,您的响应是一组客户:

...
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">\n
<customers>\n <-- REMOVE
<customer>\n
...

当您在$opt数组中使用'display'=>'full'时,您的响应是一组客户:

...
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">\n
<customers>\n <-- REMOVE
<customer>\n
...