Facebook Messenger API - Possible to generate the "Persistent Menu" user-specific? - php

I'm developing a Messenger BOT by using the Facebook Messenger Platform. I was able to create a Persistent Menu by following their guide.
I used CURL to create that menu. Which means, the same Persistent Menu is applied (appeared) to everyone.
Now, i want to know whether that Persistent Menu is customizable for different users.
As a simplest example, let's say i want to put User's Name on one of that menu items, like:
Hello John Cena!
View my Credits
View Bills
Order History
Latest News
Promotions!
Obviously, i need to do more meaningful stuffs. Like, putting different Web Links based on User. Show/hide some menu items based on User. Etc.
Please kindly suggest.
(Note: i'm using PHP for backend.)

Persistent Menu is part of Messenger Profile. Messenger Profile is the central store for your bot's properties. All Messenger Profile properties are common for the bot and cannot be made user specific. However you can personalize greeting text with user's name using {{user_full_name}}.
Note: Not sure whether {{user_full_name}} will work on persistent menu.

Related

Joomla ACL and alternative page content

We have a site where we are intending to sell access to video tutorials. I have set up Joomla ACL to limit access to those pages only to those users who have been given the relevant access permissions and access is being sold through shopping cart called MijoShop.
This setup is working okay at the moment, but there is bit of an issue with user experience. At the moment it seems I can only stop people from viewing a page, but I can't see an easy way to show them alternative content with Joomla ACL. Ideally, if a logged-in user does not have access to a certain video tutorial page, when they click on the link to the page they will instead see a page giving them an opportunity to buy access to the tutorial. This means that I need a method for showing different content on the same page depending on which Joomla user groups a user is assigned to. Is this possible with vanilla Joomla ACL, or am I going to have to find a content management extension that can add the ability to do this?
You should be able to do that with the Vanilla ACL. IIRC you can setup various groups with access to different tutorials/pages/things - then you can make a member a part of multiple groups - thus giving them access to those things as needed.
If unable to do something like that - then I think George Wilsons comment would suffice for a while and you could implement some if/then/else type statements into the code of the article which would work.
Your best bet however is to try the ACL solution first and foremost as that allows you to keep things generally more easy to manage from a backend perspective.

Create a shortlist/collection of items on a website with Facebook Like API

I have a client site where we currently have a much underused 'shortlist' feature for items listed on the website. In this case the items are properties for sale, users can add the ones they are interested in to a shortlist for future reference.
We also recently added Facebook 'Like' buttons to the website which have had a lot of use, the barrier of entry is lower (I guess) because users are already logged in to Facebook.
What I would therefore like to do is modify the property shortlist feature so that it simply displays a list of the properties that a logged in Facebook user has 'Liked' on the clients domain.
How would I get at this data (either via PHP or JS) using the Facebook API?
that's not possible out of the box. You have two possibilities:
Display a social plugin (Activity Feed) to display the recent actions (e.g. "like") on the mentioned. The plugin itself is like a drop in widget, so you can't style it at all.
Ask the user for the "user_likes" permission. If the user authenticates your app and the additional permission, you can perform a fql query to get all liked items. It's a little more complicated then (1), but with the mentioned permission you have all required data to perform the custom sort algorithm you want.

Facebook like button and OAuth Access

I am connecting to the Facebook API using HybridAuth on the server side (backend is written in PHP). This is for a SaaS publishing application that is hosted on our servers. I understand the mechanics of OAuth and that once I accquire the appropriate permissions from the user, I can write and read from the Open Graph API, which in theory will allow me to do almost anything.
The problem is that I would like to use some of Facebook's social plugins. In particular, I would like to implement the like button so that it automatically appears for each blog post, article and page.
The problem is that the like button and the various Facebook plugins require an app_id. I would prefer not requiring users to add the developer app to their account and creating an app to get an app_id as it can be a confusing process for non-developers.
Is there anyway we can create or retrieve an app_id from open graph (which we can store and use to generate the like buttons and other facebook widgets)?
With the migrations, I understand that each liked URL will not have it's own page. Once the user clicks a like button on your site, he automatically likes your page. However, let's say I have a page called http://www.mystore.com/products/some-awesome-product and there are other similiar pages, all with a like button. Is it possible that when clicking like, the user automatically likes our Facebook page, but when an item is published in their news feed for the like, the URL links to that specific product? Effectively, is there a way for users to like multiple pages from my site?
Update: It looks like we can generate app_ids programmatically with the create application API in the legacy REST API. However, this does not seem to be an option with the graph API.
Seems like we cannot programatically create an app_id for an account. This is not an issue, as we will just create a small guide to guide our users through creating an app and submitting the app_id to us using a form. Not perfect, but should be easy to implement.
As for URLs, liking something will not automatically like your Facebook page. If href is blank, the current page will be liked. If you set your facebook page in the href parameter, then your facebook page will be liked.

How to create restricted and non restricted area same time in Symfony2

what i have to build is page that have some pages that are restricted and some are not on similar links. I`ll try to explain it on example:
Let's say that i have users in my system (based on FOSUserBundle), and each of them have own account that contains a Blog and Gallery (different controllers). Some of User want to give access to thier Blog and Gallery only for certain group of people (that are not stored in system), so they generate token (only one token, so whoever know token will be able to access area) and sends to Users. What i don`t want to do is to check it in each method of controllers.
So let`s say we have 2 users, steven and stan and first of them want to make his blog and gallery free to see, but second one want to be restricted based on token.
Link would be like this:
/steven/blog
/steven/gallery
/stan/blog
/stan/gallery
Could anybody recommend some solution or any idea how can i try to build it in Symfony2?
Why don't you want to check it into the controllers ? I don't see any others ways to do that, according you want it to be dynamic and possibly changing.

PHP code to restrict member access by permissions

I am building a website in PHP & mySQL. It has frontend and backend capabilities. Only admin can enter the backend by means of username and password. Now if the admin wants to add other sub-admins to the website, he could do so. By this method, a sub-admin will be able to login and perform all actions that the original admin is able to do.
WHAT I WANT TO DO:
I want to restrict the access of the sub-admins at my choice and assign them permissions so that they are able to access only certain portions of the admin panel.
EXAMPLE OF THE FEATURE THAT I AM TALKING ABOUT:
Consider that I have the following links accessible by original admin.
1. Add articles 2. Approve articles 3. Delete Articles 4. Add User 5. Edit user 6. Delete User 7. Change site settings 8. View Financial info 9. Mail center
If I do not set any permissions, then all sub-admins will be able to access all of above links. Say I create 2 sub-admins 'David' and 'Bob'.
Now I want David to access only the following desired sections of the backend:
Add articles, 4. Add User, 7. Change site settings
Now I want Bob to access only the following desired sections of the backend:
Add articles, 2. Approve articles, 3. Delete Articles, 4. Add User, 9. Mail center
I, being the original admin, should be able to access all sections whereas, David and Bob, should be able to see & access only the links and pages (or functionality) that have been assigned to them. I don't have a clue as to how to do this. Also, for example, if I want to restrict a sub-admin to access only 'Add articles' page, then I also want him to access the page that it posts to (considering that the input is on Add articles page) add_articles_next.php page. Also note that 'add_articles_next.php page' does not appear anywhere in the list of links. It is merely a page that is posted to from the page to which the sub-admin has access.
I understand that there is no way for the system to know that unless I explicitly specify it, but yes, that's my question. How to do it? I am not a object oriented person, so PHP code using functions will be great for me.
OTHER LIVE EXAMPLES OF THE FEATURE THAT I AM TALKING ABOUT:
I came across a feature while researching this topic. Click here to visit it. This looks like somewhat similar feature.
Thank you all in advance for any code that you can give me.
This has been asked a number of times before on SO. The keyword to search for is Access Control Lists (ACL). One of the most prominent PHP solutions for ACL is Zend_ACL. It's very generic and should enable you to customize it to your needs.
Edit regarding your comment about object oriented libraries:
Finding an ACL solution that is not object oriented is going to be very, very difficult as there are very few good ACLs for PHP on the market (Zend is about the only one I know, really) and most modern applications are taking a more or less object oriented approach. But don't worry, check out the tutorials. I think you will have no problem using Zend_Acl in a function oriented app. You will need to talk to the ACL via OOP, but that's easy. I don't think you'll have to change your app much. Give it a try, and on a general note, basic OOP isn't difficult to learn. Just give the "Classes and Objects" chapter in the PHP manual a good read.

Categories