laravel 如何创建产品目录批处理,电子商务上的facebook业务sdk php

0h4hbjxa  于 2023-04-13  发布在  PHP
关注(0)|答案(1)|浏览(119)

我使用FacebookBusinessSDK11.0创建新产品类别电子商务
https://github.com/facebook/facebook-php-business-sdk
我试着看了文件,但还是看不懂。
try but show error(#100)参数requests是必需的

$api = Api::init($app_id, $app_secret, $access_token);
        $api->setLogger(new CurlLogger());

        $fields = array(
        );
        $params = array(
            'retailer_id' => 'retailer-6',
            "availability" => "in stock",
            "brand" => "Nike",
            "category" => "t-shirts",
            "description" => "product description",
            "image_url" => "http://www.images.example.com/t-shirts/1.png",
            "name" => "product name",
            "price" => "10.00",
            "currency" => "USD",
            "condition" => "new",
            "url" => "http://www.images.example.com/t-shirts/1.png",
            "retailer_product_group_id" => "product-group-1"
        );
        echo json_encode((new ProductCatalog($id))->createBatch(
            $fields,
            $params
        )->exportAllData(), JSON_PRETTY_PRINT);
sczxawaw

sczxawaw1#

$api = Api::init($app_id, $app_secret, $access_token);
        $api->setLogger(new CurlLogger());

        $fields = array(
        );
        $data[] = array(
            'method'=>'CREATE',
            'retailer_id'=>'retailer-6',
            'data'=>array(
                "availability" => "in stock",
                "brand" => "Nike",
                "category" => "t-shirts",
                "description" => "product description",
                "image_url" => "http://www.images.example.com/t-shirts/1.png",
                "name" => "product name",
                "price" => "1000", //it will be 1000 otherwise it will through error
                "currency" => "INR",
                "condition" => "new",
                "url" => "http://www.images.example.com/t-shirts/1.png",
                "retailer_product_group_id" => "product-group-1"
            )
        );
        
        $params = array(
            'access_token'=>$access_token,
            'requests'=>$data
        );
        echo json_encode((new ProductCatalog($product_catalog_id))->createBatch(
            $fields,
            $params
        )->exportAllData(), JSON_PRETTY_PRINT);

Try this one it will work.

相关问题