I am also currently using file_get_contents() mostly because I am only ever fetching a JSON array once (and it's only needed to set up a MySQL database once per event for scouting) but how I am forming it is
Code:
$jsonurl = "http://www.thebluealliance.com/api/v2/event/$eventcode/teams?X-TBA-App-Id=frc2557:pnwscout:v01"
or in your case
$jsonurl = "http://www.thebluealliance.com/api/v2/team/frc3991/2016/events?X-TBA-App-Id=frc3991:scouting-system:v01
Glad you got it all sorted out!