-1

Their PHP snippet with suggesting the PECL installation (would ideally stick with a non-PECL PHP option if exists)

Updated:

<?php    

error_reporting(E_ALL);
ini_set("display_errors", "On"); 

$query_params = array( 
    // Specify your developer key 
    'key' => 'XXXXXXX', 
);     

$getdata = http_build_query($query_params);    

$opts = array('http' =>
 array(
    'method'  => 'GET',
    'content' => $getdata
    )
);    

$context  = stream_context_create($opts);    

$response = file_get_contents('http://api.nfldata.apiphany.com/developer/JSON/UpcomingSeason?'.$getdata, false, $context);
?>

Not getting any errors through PHP syntax checker; also added attempt at enabling errors. Stumped as to why the screen is just white. Looking at standalone developer URL: http://api.nfldata.apiphany.com/developer/JSON/UpcomingSeason?key=XXXValidDeveloperKey displays '2014' when navigated to within browser. Implemented above nothing at all is displayed.

Recent Error:

 Notice: file_get_contents() [function.file-get-contents]: Content-type not specified assuming application/x-www-form-urlencoded in /home/content/69/8610569/html/SFG/nfldata/currentseason.php on line 22
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • 1
    Why not try something like this https://www.digitalocean.com/? – Bradley Trager Mar 10 '14 at 18:50
  • If you try switching to JSONP you may have better luck with the cross-site scripting issue (the security error you are running into - don't want to allow scripts from other websites to run on your page since then you open your page to being injected with bad script). If you're up for it, just get yourself a free AWS EC2 instance. Then setup a LAMP (or whatever you want) stack and forget all those restrictions on what you can/can't use. Just use GoDaddy for the domain name - not worth paying for their hosting if you are just doing basic stuff. – Matthew Herbst Mar 10 '14 at 18:50
  • 1
    There is a good chance you can do what you need without using the PECL package. Post your code and we will see. – Bradley Trager Mar 10 '14 at 18:54
  • 1
    Put the error reporting stuff on the top of your script. – Bradley Trager Mar 10 '14 at 19:51
  • Just did it!! And now get the as follows " Notice: file_get_contents() [function.file-get-contents]: Content-type not specified assuming application/x-www-form-urlencoded in /home/content/69/8610569/html/SFG/nfldata/currentseason.php on line 22" – Dr Upvote Mar 10 '14 at 20:42
  • You can ignore that *notice*; it follows from `error_reporting(E_ALL)`. What you need is something like `echo $response;` to generate any output. – PointedEars Mar 10 '14 at 22:20
  • To avoid the warning you can also specify the content type in your request header. I made an edit to my answer to demonstrate this. – Bradley Trager Mar 11 '14 at 17:21
  • I noticed you removed the first part of your code snippet. I think it would be better to leave it in so that other people can benefit from the question. – Bradley Trager Mar 11 '14 at 17:23

2 Answers2

0

Try using native PHP methods. So the code sample you provided could be converted to something like this:

<?php     

$query_params = array( 
    // Specify your developer key 
    'key' => '', 
);     

$getdata = http_build_query($query_params);    

$opts = array('http' =>
 array(
    'method'  => 'GET',
    'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
    'content' => $getdata
    )
);    

$context  = stream_context_create($opts);    

$response = file_get_contents('http://api.nfldata.apiphany.com/developer/JSON/UpcomingSeason?'.$getdata, false, $context);

?>
Bradley Trager
  • 3,570
  • 3
  • 26
  • 33
  • So, I got no errors, thats a good sign, just a white screen. Maybe I can get this! – Dr Upvote Mar 10 '14 at 19:19
  • Make sure you have error reporting on http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php. – Bradley Trager Mar 10 '14 at 19:24
  • Thanks @Bradley, I checked through a few syntax checkers and added 'error_reporting(E_ALL); ini_set("display_errors", "On");' to report errors; not getting any however stumped as to why nothing is displaying. Thanks again for help!! – Dr Upvote Mar 10 '14 at 19:44
  • @CaptainRon What are you expecting to be displayed? AFAICS you are not outputting anything, you are just storing something in a PHP variable. – PointedEars Mar 10 '14 at 19:57
  • @PointedEars - I'm trying to grab the upcoming season: https://developer.fantasydata.com/docs/services/299/operations/1115/console – Dr Upvote Mar 10 '14 at 21:18
  • @CaptainRon I *know* what you are trying (at least I think I have a fair idea of it); it does not change the fact that you are not generating any *output* with this script, so it should not be surprising to you that nothing is displayed. – PointedEars Mar 10 '14 at 22:15
0

Not getting any errors through PHP syntax checker; also added attempt at enabling errors. Stumped as to why the screen is just white.

You are not generating any output. Insert

echo $response;

right before the ?>, then remove the error-prone ?>.

PointedEars
  • 14,752
  • 4
  • 34
  • 33