how to create dynamic facebook tabs? - php

i run a website where people have their own subpages like http://www.url.com/me.php?=username or http://username.url.com
i've been reading at http://www.bentedder.com/creating-custom-facebook-page-tabs-that-load-external-urls/ on how to create custom tabs that users can then add to their facebook pages.
now, it works if I redirect users to:
http://www.url.com
but I can't get it to work so that each user can redirect to their profile at:
http://username.url.com
is there any way possible to achieve this?
UPDATE: I tried to get the tabs working like this via JSON:
www.facebook.com/dialog/pagetab?app_id=MY_APP_ID&next=https://www.url.com/me.php&app_data={"username":"joe"}
and then retrieve it via:
$signed_request = $facebook->getSignedRequest();
$app_data = $signed_request["app_data"];
var_dump($signed_request);
var_dump($app_data);
That doesn't work either :( It shows all the variables like 'algorithm', etc. EXCEPT the app_data. I'm sure I am doing something wrong somewhere but I can't figure out what...

I may not be clear on the question, but I think your issue lies within the set up on facebook. For a tab or page to appear within a facebook page or tab it must be included as a domain in the app settings. Bear in mind that almost everything you add to facebook is called an "app" by them. An extra tab is an "app" and so forth.
I did notice, but I am sure that it is simply an example that you are using that you are using the http protocol and not the https protocol. Facebook pretty much demands that all pages and sites that are used in this way use SSL. Just a sub-thought.

Related

Adding an Application (NOT tab) to a page

I use an application added to a Facebook page to subscribe to real-time updates which has worked fine and still works fine. However, the old way of adding an application to the page using add.php seems to redirect to the dialog for adding pagetabs now.
Add.php: https://www.facebook.com/add.php?api_key=XXX&pages=1&next=URL
This no longer works and redirects to:
https://www.facebook.com/dialog/pagetab?api_key=XXX&next=URL
This would be fine if we could use the application on the page without displaying an empty pagetab on the wall.
So does anyone know of any changes to this process and a new way to add an application to a page as an application and not a pagetab? Will this require using the Graphi API and manage_pages permission to do it or is there a simple URL method we can follow?
Thanks in advance.
Here is the correct way to add an Application to a page that is not a page tab.
https://developers.facebook.com/docs/graph-api/reference/page/tabs/
Basically the old add.php method has been removed but you can still add applications that do not contain a pagetab to a page by making the following call:
POST: /{page-id}/tabs
app_id = {app-id}
is_permanent = false
you need the page access token to do this.
Further information can be found in the bug report here: https://developers.facebook.com/x/bugs/779220265438820/
Thanks to Pragati on that bug report who pointed me in the right direction.
This is no longer possible to do.
You can get part of the way there with Open Graph objects, but they don't give you any ability to run code on the page and are restricted to particular display typesl

Is it possible to create FB Apps with script?

I'm building a product that involves clients adding their FB app data into my product's dashboard.
In this case each client would have to go to developers.facebook.com/apps and create an app first.
I would want to have a button which says "Create App" in my website that when clicked, would create the app instantly for the client.
So is it possible to create a FB App from my website (with script, not manually) ??
Thanks in advance,
Altin.
It was possible couple of years ago, and now it's been removed.
First of all, I’d think about the question, “does every client really need their own app?”
Maybe it’d also be possible to have all of the stuff you’re planning to do (no details on that) under one app, and have it decide on what data to show based on the fact which client’s Facebook page it gets added to (if it’ll run as page tab app), or by some additional parameter passed to it when calling it. You could f.e. example automatically redirect to a sub-folder on your webspace based on this criteria, that displays individual pages for that client.
If that’s not an option, then yes, your clients will have to set up the basic app themselves (and therefor they’ll need a verified account) – and afterwards tell app id and secret to you. Many of the “advanced” app settings can then be set by you via script – look at what properties are marked as “(Editable via API)” here: https://developers.facebook.com/docs/reference/api/application/
(Although some of the basic settings, like category, description, logo etc. will still have to be set by your client themselves. But other, more “technical” stuff, that the client maybe doesn’t know about and doesn’t even want to be bothered with, like canvas/page tab URLs etc. can be set by you. I’d say that’s as good a compromise as you can get for such a scenario.)

Facebook like button doesn't remember "likes" (keeps resetting on refresh)

I have an app that creates dynamic pages for users with like buttons.
The button works on all of the pages, but when I refresh the pages some of them don't "remember" the like count (or that I liked the page a second ago), while others work perfectly.
Here's an example of a page that remembers the like count: www.teespring.com/teespring
And one that doesn't work: www.teespring.com/brownrugby
The problem lies the value of the meta tag fb:admin. Here is what you have published -
"102628019845885" is not a valid Facebook user id. Please correct it and your users would be able to "Like" your page.
Well, you can debug such issues yourself, just go to Facebook tool - http://developers.facebook.com/tools/debug
I figured it out earlier today after spending few hours while debugging a similar issue for my app http://www.jokeshive.com
If you monitor your network traffic while you click the like button, you can an XHR request to Facebook to create the Like for the user.
You will see when you click the like button, Facebook makes this request, and returns a JSON string with the status. Yours actually fails and here's the relevant part of the returned response.
"payload":{"requires_login":false,
"error_info":{"brief":"App ID does not match domain",
"full":"The app ID specified within the \"fb:app_id\" meta tag is
not allowed on this domain. You must setup the Connect Base Domains
for your app to be a prefix of http:\/\/teespring.com\/brownrugby.","errorUri":"\/connect\/connect_to_node_error.php?
title=App+ID+does+not+match+domain&body=The+app+ID+specified+within+the+\u002522fb\u00253Aapp_id\u002522+meta+tag+is+not+allowed+on+this+domain.+You+must+setup+the+Connect+Base+Domains+for+your+app+to+be+a+prefix+of+http\u00253A\u00252F\u00252Fteespring.com\u00252Fbrownrugby.&hash=AQAacTBYi-g6Czel"},
From this response, it seems like there's an issue with the domain configuration of your application, or the app id configuration of your open graph object pages.
Hopefully this helps and points you in the right direction.

When creating a facebook tab, how can i check if the user is accessing the page through facebook

I am trying to put a redirect on the iframe page I am creating for a facebook tab to make sure that those accessing the pages outside of FB will be directed to the application.
Everything I have done so far has caused problems with the meta data not being able to be accessed by FB and so on with the redirect causing a conflict.
Does anyone know how to do this?
The best way to know that you are inside a facebook iframe is to check and see if you have been passed a signed_request (and that it is valid).
Here is a link to another SO question that dealt with the same sort of issue.
How to know if my page is running in a facebook iframe or not

.htaccess twitter or facebook URL naming convention

For my Social Networking Site, I would like to build a facebook, or twitter similar URL rewriting naming convention.
Using Twitter as an example, they have pages labeled twitter.com/about and another page labeled twitter.com/{$username}
However, how do you differentiate between say a user who has registers on to our site as "about" then. From this we are going to have a server conflict between the user "about" and the page about.
What is the best way to handle this?
Usually, you'll see this implemented so that conflicts are not possible. For instance, you could camp all users inside a virtual /users directory, or a subdomain: mysite.com/users/msilvis, or users.mysite.com/msilvis.
I would not recommend that you make all users accessible via the root directory of your site, because this could potentially restrain you from adding pages. For instance, suppose you do not have yet an "about" page, but a user registers and calls itself "about"; you're screwed.
If you still choose to do so, before registration, try an HTTP request to your website to the page the user would have. If you don't get a 404, then something already has that name.
What our final decision came down to, was upon requesting a page on our server mysite.com/user, it first checked to see if that was a page, if it IS NOT a page, it assumes that it is a user, in which case it checks to see if that user is an object, if it is not then it gets passed to our 404 page.
So ontop of this, we are going to use the HTTP request like you mentioned earlier, and then if some how user "about" still signs up which we now have a page for, essentially sucks to be him because he is not going to see his page.
I would restrict the ability for someone to create a username that would conflict with existing urls.
If you're still in the early stages of development, you could look at the Kohana PHP framework. It's routing features solve the problem highlighted by zneak and dd, you would simply define in your routes that http://yoursite.com/about would point to a particular controller/action, i presume you're using the MVC design pattern considering you want a twitter like url structure.
Hope that helps!
EDIT: I forgot to mention that this doesn't stop people from signing up as about, it would just prevent the rest of the world from being linked to that persons page, in order to prevent them you'd need to employ some kind of validation against your core pages aka about, contact ect.

Categories