Skip to main content
Question

Trouble downloading box.com files via PHP

  • May 21, 2025
  • 6 replies
  • 40 views

Forum|alt.badge.img
Approx 2 years ago I wrote a PHP program that run daily and pulls small audio-clips file from a box.com account and emails the files as email attachments.  This program has been working smoothly for approx 2 years and just recently broke.  Now, when the attachment is sent, it is not playable as an audio file.  If you try to open it with any media player, you get an error that the file is not playable.  
 
I took some time today to look into this bug.  I see that when I open the file in Notepad, I see an almost empty file, with a few digits at the start.  For example, this file:
 
generates a file that contains only the digits:
6145253
Obviously, I can't play that with a media player.
 
Here is the PHP code that I have been using without trouble until recently:
 
 
$fileURL = "https://app.box.com/shared/static/eox58nirjaxm5g4vo5n088l76dudzum4.mp3";
header('Content-Type: audio/mp4');
copy($fileURL, "/home/alivein5/public_html/email-system/attachments/".$fileName);
 
I spent a long time on this and didn't get anywhere.  Has anything changed recently?  Should I be using  box.com API functions instead of my own PHP code??  
 
I would appreciate any support here.
 
Thank you,
NS
 

6 replies

Forum|alt.badge.img

Hello 

I used to code some PHP way back in versions 2 and 3.  Has the function changed?  I do see that the URL you provided is legitimate and working.  Is the box page you're pulling the MP3s from your own box site - or someone else's?  You may be better off with box APIs - I've not looked at them but I'm sure they can provide what you want.

 

Another idea would be to actually post this question on the developer board here

 

Good Luck!


Forum|alt.badge.img

 This sounds like a possible bug. Just to confirm where the issue is, can you please check if you are able to play the audio file in the web app?


Forum|alt.badge.img

Sorry, I'm unclear what you are asking.  Can you clarify where you want me to go to confirm that I can play the file in the web app?  (What web app?)

 

Thanks!


Forum|alt.badge.img

Thanks for your response.  The box URLs that I'm pulling from are all in my own Box.com account.  I am not familiar with the Box.com API, and I looked but didn't find what you are describing.  Can you point me in that direction?

Thanks again!


Forum|alt.badge.img

Hi Murtza,  I'm surprised that I haven't gotten a response back from you.  I'd appreciate any support here. Thanks!


Forum|alt.badge.img

 Sorry for my slow response. I would recommend filing a support ticket to help debug this further.