Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
I am trying to install an Instagram Feed on my website and after some research found the following code to use in php.
I inserted in the PHPlugins as below and have errors - any ideas please?
function ttg_canvas_bottom( $style, $path ) {
echo '
$client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$user_id = 'xxxxxxxxx';
$url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?client_id='.$client_id;
$data = file_get_contents($url);
$json = json_decode($data);
$first_photo = $json->data[0];
// Change "standard_resolution" to "thumbnail" or "low_resolution"
$image = $first_photo->images->standard_resolution;
?>
<img src="<?php echo $image->;url; ?>;" alt="" /></pre>
Caption: <php echo $first_photo->caption->;text; ?>;
Created on <?php echo date("F j, Y, g:i a", $first_photo--->created_time); ?>;
User: <?php echo $first_photo->user->;full_name; ?>; (Username <?php echo $first_photo->user->;username; ?>;)
<img src="<?php echo $first_photo->;user->;profile_picture; ?>;" alt="" />
';
return false; // Replaces normal menu
} // END
Offline
One problem is the single quotes inside the echo'
try either escaping them:
$client_id = \'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\';
$user_id = \'xxxxxxxxx\';
$url = \'https://api.instagram.com/v1/users/\'.$user_id.\'/media/recent/?client_id=\'.$client_id;
or changing them to double quotes:
$client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$user_id = "xxxxxxxxx";
$url = "https://api.instagram.com/v1/users/".$user_id."/media/recent/?client_id=".$client_id;
Do this in a plain text editor like Notepad++ for Windows or TextWrangler for Mac.
After you've made these changes there may be other problems, but fix that first.
Note: don't escape or change the final single quote near the end of the function
';
return false; // Replaces normal menu
} // END
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Thank you, that removed all syntax errors.
Now I just see the code (as text) in the website.
I'm sure it is a simple fix and I am doing something wrong.
Any ideas please?
function ttg_canvas_bottom( $style, $path ) {
echo '
$client_id = "xxx";
$user_id = "xxx";
$url = "https://api.instagram.com/v1/users/".$user_id."/media/recent/?client_id=".$client_id;
$data = file_get_contents($url);
$json = json_decode($data);
$first_photo = $json->data[0];
// Change "standard_resolution" to "thumbnail" or "low_resolution"
$image = $first_photo->images->standard_resolution;
?>
<img src="<?php echo $image->;url; ?>;" alt="" /></pre>
Caption: <php echo $first_photo->caption->;text; ?>;
Created on <?php echo date("F j, Y, g:i a", $first_photo--->created_time); ?>;
User: <?php echo $first_photo->user->;full_name; ?>; (Username <?php echo $first_photo->user->;username; ?>;)
<img src="<?php echo $first_photo->;user->;profile_picture; ?>;" alt="" />
';
return false; // Replaces normal menu
} // END
Offline
Where did you get that code and do you have instructions as to where to place it?
ttg_canvas_bottom places stuff on the page itself.
And it looks like more of that code should be wrapped in php tags, like those variables at the beginning. They might belong in the <head> (ttg_head_end hook)
And there are html errors like a closing </pre> tag when there is no opening tag.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Hard to say what's going on, but that code, to me, looks like it's full of syntax errors.
$image->;url; is probably meant to be $image->url;
echo $first_photo->user->;full_name; is probably mean to be echo $first_photo->user; echo full_name; or echo $first_photo->user->full_name;
But really, this is some of the messiest PHP I've ever seen, so it's difficult to know what the intent is, and I'm certainly no PHP expert.
Offline
Pages: 1