[英]Unable to capture WooCommerce REST API request which is causing PHP error
[英]Woocommerce Rest API: Error: An error occurred in the request and at the time were unable to send the consumer data
我正在使用 Woo-commerce 官方 rest sdk 在我的 Laravel 5.6 站點中集成 Woo-commerce API。 我使用身份驗證端點 URL 創建了一個鏈接。 這里提到了這一點。
當用戶點擊鏈接時,它會將用戶帶到 Woo-commerce 身份驗證頁面,用戶在該頁面登錄並批准請求。
批准請求后,我應該返回我在鏈接中提到的 url。 相反,它向我顯示了以下錯誤。
錯誤:請求中發生錯誤,當時無法發送消費者數據。
這是我的代碼。 `$store_url = 'YourStoreUrl';
$endpoint = '/wc-auth/v1/authorize';
$params = [
'app_name' => 'YourApplicationName',
'scope' => 'read_write',
'user_id' => 'yourUserId',
'return_url' => 'YourStoreUrl/callbackurl',
'callback_url' => 'YourStoreUrl/returncallback'
];
$query_string = http_build_query( $params );
$url = $store_url . $endpoint . '?' . $query_string;`
對於將來可能遇到同樣問題的用戶,請確保您的callback_url
是正確的。 錯誤主要是由於callback_url
。
就我而言,我最初有這段python
代碼:
store_url = 'http://localhost/wordpress'
endpoint = '/wc-auth/v1/authorize'
params = {
"app_name": "My app",
"scope": "read_write",
"user_id": 123,
"return_url": "http://localhost/wordpress/",
"callback_url": "https://f46c7c857579.ngrok.io",
}
query_string = urlencode(params)
return "%s%s?%s" % (store_url, endpoint, query_string)
但是我的callback_url
是錯誤的。 當我輸入正確的callback_url
,錯誤消失了。 callback_url": "https://f46c7c857579.ngrok.io/return"
另外,請確保您的callback_url
具有POST HTTP METHOD
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.