foucquet Posted October 23, 2012 Share Posted October 23, 2012 (edited) I am trying to bring a flickr feed into a webpage, and can't work out why this:- <?php // >>> Set up the variables needed <<< $photos = array(); $encode_params = array(); $maximgs = 19; // >>> This need to be 1 less than actual req'd No. as array counts from 0 <<< // >>> Set up the parameters for the API <<< $api_params = array( 'api_key' => 'my api key', 'method' => 'flickr.photos.search', 'user_id' => 'my id', 'format' => 'php_serial', ); //>>> Encode the parameters ready to make API request <<< foreach($api_params as $k => $v){ $encode_params[] = urlencode($k) . '=' . urlencode($v); } var_dump($encode_params); // >>> Construct API url and make the request <<< $api_url = 'http://api.flickr.com/services/rest/?' . implode('&', $encode_params); var_dump($api_url); // >>> Retrieve images <<< $rsp = file_get_contents($api_url); $rsp_obj = unserialize($rsp); echo $rsp_obj; var-dump($rsp_obj['photos']['photo']); //>>> Line 37 <<< ?> gives me "Parse error: syntax error, unexpected T_VAR in C:\wamp\www\php\flickr tests\prev3~.php on line 37". Edited October 23, 2012 by foucquet Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 23, 2012 Share Posted October 23, 2012 Really? you don't see anything wrong with "var-dump" ?? Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 23, 2012 Share Posted October 23, 2012 (edited) $api_params = array( 'api_key' => '1b6e67959f14d79c2c9c568b02c23f23', 'method' => 'flickr.photos.search', 'user_id' => '49466419@N05', 'format' => 'php_serial', ); Also, there is a comma after the last element - indicating that there should be another element in the array. Edited October 23, 2012 by Psycho Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 23, 2012 Share Posted October 23, 2012 (edited) Commas at the ends of the array declaration are valid, oddly enough. There are two places in PHP where errant commas are valid: 1) Trailing commas in array declarations: $a = array( 1,2,3, ); 2) Initial commas within list(): list(,$a) = explode(",", $Foo); Edited October 23, 2012 by ManiacDan Quote Link to comment Share on other sites More sharing options...
foucquet Posted October 23, 2012 Author Share Posted October 23, 2012 (edited) OK, OK, I'm a complete dummy - didn't even spot those errors, too busy looking for everything but the bleedin' obvious! That indeed now works (hides head in shame!) Edited October 23, 2012 by foucquet Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.