Woocommerce api集成柱在流明中不工作

Woocommerce api集成柱在流明中不工作,woocommerce,lumen,Woocommerce,Lumen,我目前正在从事一个需要与WooCommerceAPI集成的项目。我正在使用lumen中的路由器编写端点。我已经成功地完成了get方法。对于post http,响应正在抛出Not Allowed方法 以下是我的邮政编码示例: $router->post('/post_order', function () { //$name = $request->input('name'); $woocommerce = new Client( env('WOOC

我目前正在从事一个需要与WooCommerceAPI集成的项目。我正在使用lumen中的路由器编写端点。我已经成功地完成了get方法。对于post http,响应正在抛出Not Allowed方法

以下是我的邮政编码示例:

$router->post('/post_order', function () {
    //$name = $request->input('name');


    $woocommerce = new Client(
        env('WOOCOMMERCE_URL'),
        env('WOOCOMMERCE_CONSUMER_KEY'),
        env('WOOCOMMERCE_CONSUMER_SECRET'),
        [
            'wp_api' => true,
            'version' => 'wc/v2',
        ]
    );

    $data = [
        'payment_method' => 'bacs',
        'payment_method_title' => 'Direct Bank Transfer',
        'set_paid' => true,
        'billing' => [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'address_1' => '969 Market',
            'address_2' => '',
            'city' => 'San Francisco',
            'state' => 'CA',
            'postcode' => '94103',
            'country' => 'US',
            'email' => 'john.doe@example.com',
            'phone' => '(555) 555-5555'
        ],
        'shipping' => [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'address_1' => '969 Market',
            'address_2' => '',
            'city' => 'San Francisco',
            'state' => 'CA',
            'postcode' => '94103',
            'country' => 'US'
        ],
        'line_items' => [
            [
                'product_id' => 93,
                'quantity' => 2
            ],
            [
                'product_id' => 22,
                'variation_id' => 23,
                'quantity' => 1
            ]
        ],
        'shipping_lines' => [
            [
                'method_id' => 'flat_rate',
                'method_title' => 'Flat Rate',
                'total' => 10
            ]
        ]
    ];


    $order = $woocommerce->post('orders', $data);

    return response()->json($order);
});

您应该在帖子中引用完整的错误,而不仅仅是含糊其辞地提及它们。以下是错误截图(1/1)方法在RouteRequests.php(第228行)的应用程序->handleDispatcherResponse(数组(2,array('post'))的RouteRequests.php(第164行)的应用程序->Laravel\Lumen\Concers\{closure}()的RouteRequests.php中不允许HttpException(第413行)在应用程序->发送RouteRequests.php中的管道(数组(),对象(闭包))(第166行)在应用程序->发送RouteRequests.php中的调度(null)(第107行)在应用程序->运行()在index.php中(第28行)你的帖子;不要在评论中留下基本信息。