Trouble downloading box.com files via PHP
[Note: I originally posted this here https://community.box.com/t5/Box-Developer-Forum/Trouble-downloading-box-com-files-via-PHP/m-p/35105/highlight/false#M2167 but am not getting much a response there and someone suggested that I post it here in the developer forums. I'd really appreciate if someone can help me out... ]
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?? If so, can someone point me to the API, for some reason I'm having a hard time finding it.
I would appreciate any support here.
Thank you,
NS
Please sign in to leave a comment.
Comments
0 comments