Hi there! We've been using a script on the front page of our site for a while that includes a "Read More" link that takes users to view the most recent post made from our org's account.
Recently, I noticed the "Read More" link no longer functions properly and links back to our homepage instead (alumni.pitt.edu). I've been troubleshooting this problem on my end and can't seem to find an answer, so I'm throwing this at you guys.
Our script code is below. The inner html containing the read more link is at the very bottom.
var facebookFeeds = new Array();
window.fbAsyncInit = function() {
FB.init({
appId : '1421026271492167',
cookie : true,
xfbml : true,
version : 'v2.0'
});
getFacebookPosts();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getFacebookPosts(){
/* make the API call */
FB.api(
"/pittalumni/posts",
"get",
{access_token: access_token, limit: 3},
function (response) {
console.log(response);
if (response && !response.error) {
var postsArray = response.data;
for(var i = 0; i < postsArray.length; i++){
var title = postsArray[i].message;
var picture = postsArray[i].picture;
var link = "";
if(postsArray[i].actions)
link = postsArray[i].actions[0].link;
facebookFeeds.push([title,picture,link]);
}
}
loadFaceBookTab();
}
);
}
function loadFaceBookTab(){
var title = "";
var picture = "";
var link = "";
var latest_post = facebookFeeds[0];
if(latest_post[0] != null && latest_post[0] != ""){
title = latest_post[0];
}
if(latest_post[1] != null && latest_post[1] != ""){
picture = latest_post[1];
picture = picture.replace("w=154&h=154","w=484&h=252");
picture = '<img src="' + picture + '" width="484" height="252"></img>';
}
if(latest_post[2] != null && latest_post[2] != ""){
link = latest_post[2];
}
if(document.getElementById("panelFB")) {
document.getElementById("panelFB").innerHTML = '<div class="social-feed"><div class="row"><div class="small-5 column social-title"> </div><div class="small-2 column account"><i class="fa fa-facebook"> </i></div><div class="small-5 column social-title"> </div></div><div class="feed"><p>' + title + '</p><a class="read-more" href="' + link + '" target="_blank">Read More</a><a class="social-account" href="https://www.facebook.com/pittalumni" target="_blank">FOLLOW US ON FACEBOOK</a></div></div>';
}
}
Are these dummy access tokens? If not, then it looks like your token expired, this was way back in July however. I'd check that first - you might also want to remove your access tokens from your post.
Unfortunately, I was brought on way after all of this was setup and coded, so I have no clue what the previous person used in my position. That's the battle we're facing here, and a lot of our site's core files are locked through a combination of our central communications department and our old employee. I was able to find out that we're actually using version 2.1 of this script.
Any thoughts as to why this one also doesn't work? (I don't mind our access tokens in posts if it means we can find a solution to this.)
//var access_token = 'CAACEdEose0cBAObDw9PpcMekaazOGLLgFHKmmsxDEiLgQGWuPTPlDESVbMP60p9q4ONJiTnJMkDHASdhutZA36cZCaBXqTbS5XTZBTZAG3W0jm2JoDBHem0Eb1iRZCLKStGHkuyH6UZC0E89VRAb1fn1sZBR8gvBZCnyKq9lPZC5zD4FpOf6dZABrfvm9vEVV3RmkZD';
var access_token = '585225254917163|AsEUlfpv24u1AKK6zhg0SB4NsbY';
var facebookFeeds = new Array();
window.fbAsyncInit = function() {
FB.init({
appId : '585225254917163',//'1421026271492167',
cookie : true,
xfbml : true,
version : 'v2.1'
});
getFacebookPosts();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getFacebookPosts(){
/* make the API call */
FB.api(
"/pittalumni/posts",
"get",
{access_token: access_token, limit: 3},
//grant_type=client_credentials&client_id='.$appid.'&client_secret='.$secret);
function (response) {
console.log(response);
if (response && !response.error) {
var postsArray = response.data;
for(var i = 0; i < postsArray.length; i++){
var title = postsArray[i].message;
var picture = postsArray[i].picture;
var link = postsArray[i].link;
//if(postsArray[i].actions)
// link = postsArray[i].actions[0].link;
facebookFeeds.push([title,picture,link]);
}
}
loadFaceBookTab();
}
);
}
function loadFaceBookTab(){
var title = "";
var picture = "";
var link = "";
var latest_post = facebookFeeds[0];
if(latest_post[0] != null && latest_post[0] != ""){
title = latest_post[0];
}
if(latest_post[1] != null && latest_post[1] != ""){
picture = latest_post[1];
picture = picture.replace("w=154&h=154","w=484&h=252");
picture = '<img src="' + picture + '" width="484" height="252"></img>';
}
if(latest_post[2] != null && latest_post[2] != ""){
link = latest_post[2];
}
if(document.getElementById("panelFB")) {
document.getElementById("panelFB").innerHTML = '<div class="social-feed"><div class="row"><div class="small-5 column social-title"> </div><div class="small-2 column account"><i class="fa fa-facebook"> </i></div><div class="small-5 column social-title"> </div></div><div class="feed"><p>' + title + '</p><a class="read-more" href="' + link + '" target="_blank">Read More</a><a class="social-account" href="https://www.facebook.com/pittalumni" target="_blank">LIKE US ON FACEBOOK</a></div></div>';
}
}
If it's an access token issue, I've tried generating new ones from Facebook and plugging them in, but I still can't get this resolved. So, unless I'm doing that wrong, which is very likely, I'm not sure where else to go with this one.
Thanks Katlynn, I've just tested this one and it seems to work okay. It doesn't look pretty but I get the feed back just fine.
Could your JS be cached? Either try a hard refresh in your browser or increase the version number in you ClientDependency.config file if Umbraco is caching the old file.
Facebook "Read More" script broken
Hi there! We've been using a script on the front page of our site for a while that includes a "Read More" link that takes users to view the most recent post made from our org's account.
Recently, I noticed the "Read More" link no longer functions properly and links back to our homepage instead (alumni.pitt.edu). I've been troubleshooting this problem on my end and can't seem to find an answer, so I'm throwing this at you guys.
Our script code is below. The inner html containing the read more link is at the very bottom.
Hi Katlynn,
Are these dummy access tokens? If not, then it looks like your token expired, this was way back in July however. I'd check that first - you might also want to remove your access tokens from your post.
Hey Ben,
Unfortunately, I was brought on way after all of this was setup and coded, so I have no clue what the previous person used in my position. That's the battle we're facing here, and a lot of our site's core files are locked through a combination of our central communications department and our old employee. I was able to find out that we're actually using version 2.1 of this script.
Any thoughts as to why this one also doesn't work? (I don't mind our access tokens in posts if it means we can find a solution to this.)
If it's an access token issue, I've tried generating new ones from Facebook and plugging them in, but I still can't get this resolved. So, unless I'm doing that wrong, which is very likely, I'm not sure where else to go with this one.
Thank you! :)
Thanks Katlynn, I've just tested this one and it seems to work okay. It doesn't look pretty but I get the feed back just fine.
Could your JS be cached? Either try a hard refresh in your browser or increase the version number in you
ClientDependency.config
file if Umbraco is caching the old file.is working on a reply...