Recently viewed pages in AEM - aem

I am trying to implement a feature where user can see what all last 5 pages he visited during current session. This is for anonymous user as site does not have any login/registration module available.
I can think of creating a data structure in user current session and add page names there and as user browse page from page, add page name in that collection using either request post processor or in a servlet. This servlet can be called using a HTL component passing json data to UI. Challenge here would be to maintain a consistent user session across journey.
OR
I can use some third party tool say Adobe analytics or Target etc for same?
Any suggestion?

Related

Fetching and displaying linkedin company updates on my page

I am building a laravel project, in which I wish to fetch articles from my company page on linkedin and display them there.
However, before I can consume the API, it requires me to log in as a linkedin user.
How can I get the articles without logging in?
For a nice and good workaround you should use the API, and yes you need an account for that. There are other options, they can be very slow and isn't very stable. In that case, you need to open with PHP al the content from an URL and walk through every div and use that data on your own wat.
More information about that (PHP, XPATH);
Retrieve the contents of a div from external site (PHP, XPATH)?
I hope this is relevant to your question and helps you.

Facebook API: find out whether private message links into business manager or not

When fetching page conversations, I receive a link field. This link field is an absolute path, without the server, e.g. /PAGE-12312/manager/messages/?mercurythreadid=....
Depending on whether a page is managed via the "Facebook Business Manager" or not, that link should be either opened via facebook.com or business.facebook.com.
How can I find out whether the FB page is managed via the business manager, i.e. how can I know how to properly construct the link back to facebook?
Linking to a private messages on a page managed via the business manager does not word, i.e. opening facebook.com/PAGE-12312/manager/messages/?mercurythreadid=.... leads to an error.
The business field on the /{page-id} node in graph api is the ID of the business that owns the page in Business Manager, if any. It's only available with a page admin token.
You have to ask explicitly for the field in the api-request:
/{page-id}/?fields=business
The way we solved worked this around is by realizing that you can always link into the Business Manager, even when the page doesn't have it activated.

2-way syncing content between Facebook page and website

I'm planning on launching a website and an accompanying facebook page. Although each of these 'sites' will have their own goal, I'd like to have a 2-way sync set-up for part of the user generated content on my site, such that:
Content published on my site (by editors, or users) that satisfies some criteria are pushed to the wall of the accompanying facebook page
The other way around: content published on the facebook page wall by users, is pushed to my website. (I want to be in complete control of how to format, display, annotate that content, so I'm not looking for some ready-made widgets)
For 2. I'm pretty sure I can poll for a newsfeed or channel of the specific facebook page at regular intervals, but I'm wondering if a tighter integration is possible, i.e: pushing the changed content(delta's, river whatever you want to call it) to a dedicated rest-endpoint from which my website can consume the contents or something.
For 1. I need an automated way to post to the wall of the facebook page I own. Preferrably with the user-credentials (if okayed by the user) if that user was logged-in on my site through Facebook, or otherwise with some fallback credential, e.g: my own facebook credentials.
Just looking for some pointers where to start looking in the vast Developer Facebook resources, or, better yet, some libraries (prefferably Node.js, but others are okay to look at architecture) that take care of some of the plumbing
1) You can post on page with different ways
as a user : You need user access token and he should be a fan of the page or If your fan page allows wall posts from any user in its settings.
as a page : You need page access token
You can get page access token and extend it for long time and store it in DB. You can use it 60 days.
FYI:
Extended access token
Tutorial
2) Using graph API you can pull at regular intervals. There is a real time notification system also but it very limited for pages (its not useful for your case).
FYI: Real Time Updates

Implementing metatags for open graph

Facebook needs the url of the object when sending a action post request. Now , my app only allows authorized users, I redirect the user to the login page and it redirects back to the user requested page.
But how do I differentiate between fb trying to access the metatags(while posting) or users coming from fb whom I have to redirect ?
You missed some concepts behind of OpenGraph. All objects should have a publicly accessible representing page.
Citing Publishing Objects section from Facebook's OpenGraph Objects documentation:
Open Graph Objects are simply your web pages with Open Graph meta tags. Before you can publish an Open Graph object, you must define its corresponding object type in the Open Graph section of the Developer App. Once you have defined your object type in the tool, you must create a publicly accessible web page that represents your object using Open Graph metatags. We provide boilerplate metatags that you can use to create this web page in the Developer App (click the Get Code link next to your object definition). With these tags in place, you can publish actions that refer to your object.
When Facebook sees the first action applied to your object, we will scrape your page, read its meta tags and connect the user to your object, via the action. Every 7 days after the initial scrape of your object, we will attempt to re-scrape your object to keep the object data up to date.
The problem was to differentiate between a Facebook crawler and a user.
I don't remember the exact thing I wrote, but the general idea was that facebook parser just reads the html head tags . I added a fb redirect which sends the authenticated user to the desired page . This redirect wouldnt affect the crawler because javascript isnt executed by a crawler.
Now , since my need was to allow only authenticated users to go ahead, the FB js api handled auth as well. :)
Do tell me , if you need to know the specific fb api call.

Facebook graph API returns empty data for a page

I have an application that is retrieving data from Facebook. Users authorize the application to read and write to their pages, and we read their data and post to it from our application. All interaction occurs via the PHP interface that Facebook supplies.
For the last few months our application has been performing this task flawlessly. However in recent days we have started noticing an issue with certain pages.
We go out and retrieve data for a specific page, and we no longer get any data. Instead Facebook returns us an empty result. This obviously causes problems in our application which needs to read this data.
We can still write data just fine.
I am at a point where I'm not sure what this could be. Any common scenarios or recent Graph API issues that could cause this?
This sounds odd. The only thing that comes to mind is that the page owner has put a restriction on the audience for their page, which would then require you to pass in an access token to access data about the page. An example would be a beer company that wants to limit access to their FB page to users that are older than 21. Since there is a restriction on who can access the page content, we enforce that restriction on the FB platform. In this case you would need to pass in the access_token of a user who is 21 or older to access the page details via the graph api.
Adding to Jeff's answer, I found that any kind of restriction whatsoever will return a blank data object. I was banging my head on every single setting on my company's page and found that we had it set to only show in certain countries (Manage Settings > Country Restrictions). Removing all of them from the list started to return all the data we needed.