Skip to content

Commit f23f866

Browse files
committed
Explain wp_remote_get issue
1 parent 8aa8ba6 commit f23f866

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/Controllers/ProductController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ function enable_post_email_notifications() {
160160
$post_mime_type = isset( $allowed_mime_types[ $file_extension ] ) ? $allowed_mime_types[ $file_extension ] : 'image/jpeg';
161161
$filename = $product->id . '.' . $file_extension;
162162

163-
//$image_response = wp_remote_get( $product->product_image );
164-
//$image_data = wp_remote_retrieve_body( $image_response );
165-
163+
// This code results in '429: Too Many Requests"
164+
/*
165+
$image_response = wp_remote_get( $product->product_image );
166+
if ( ! $image_data = wp_remote_retrieve_body( $image_response ) ) {
167+
echo 'Error: ' . json_encode( $image_response );
168+
exit;
169+
}
170+
*/
171+
166172
$image_data = @file_get_contents( $product->product_image );
167173

168174
if ( filter_var($product->product_image, FILTER_VALIDATE_URL) && $image_data )

0 commit comments

Comments
 (0)