403 status code while accessing image from CDN services

Highlighted
New Member
2 0 0

Hello everybody,

I came into problem while trying to access and images from CDN. I get Image from API successfully, and I want to get that image's MIME. For that purpose I am using PHP function getimagesize(). Example:

$imageUrl =  'https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1543344906'; // certain image is from API docs, but it's all the same with my stores images. 

getimagesize($imageUrl);

And I get this error after execution: 

failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden.

Why am I getting 403 code and how I could avoid it?

 

UPDATE:

It works, when making request with a CURL as any browser. The problem is that in the past, all these request worked without need to make the request as user agent.

 

0 Likes
Highlighted
Shopify Expert
9928 104 1765

What user_agent as you specifiying? I know almost zero about php so have no awareness if you're able to event set that as part of your function call.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
New Member
2 0 0

Thanks Jason, I forgot to provide some critical details. I Updated my post, It works when making a request as user-agent. In the past it worked without it. So I am wondering why did this happened.

0 Likes