IU am trying to create my first Application running inside an Facebook Canvas/IFRAME. I am using
Zend Framework (PHP) for this project.
But I am not able to understand all the different ways facebook is offering.
There is an PHP SDK wich works so far. There is an Javascript SDK and something called FBJS? Does someone know a good point to start? The Documentation is not up to date most times.
I have managed it to login, and show my picture and name inside the app, the basic stuff is working.
Canvas App - facebook puts your code directly to the page (well, kind of), you have access to FBML (facebook specific tags), limited HTML, CSS (cached on Facebook side) and limited JS known as FBJS (a wrapper for native JS commands for security reasons, no jquery or anything like that). Your canvas app is still hosted on your server though, and you can use Facebook PHP API on a server side (and anything else you wish, it's a page on your server).
Frame App - facebook just puts an iframe on the page embedding some page on your server. Iframe could contain anything you want, it is just a regular page with no extra requirements. You can use HTML, JS (jquery etc), Facebook PHP API on server side. There is no FBJS as it is not needed, but you can use JS API (with similar functionality to PHP API, only for frontend). FBML is not directly supported, but you can use FBML tags on any site after declaring them:
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
Advantages of using Canvas App - no annoying iframe scrolling, quick access to FBML, and more close integration as a whole.
Facebook JS is how you can use your own javascript in a facebook page, without colliding with or interfering with facebook. It does this by rewriting your javascript, therefore you need to work around how the javascript is rewritten, and use facebook's provided library for ajax and events, not your own such as jQuery, and in a lot of cases, not even the browser's native api.
The javascript SDK allows you to access facebook data from another site using javascript. The Social Graph API has increased the potential for this access, and also has expanded it's power.
Serverside data access = through the provided php api.
Clientside data access = through the javascript SDK.
FBJS, on the other hand, is facebook's adoption of javascript for canvas applications.
Related
I'm creating an applition that crawls a website, logs in to an account and accesses the user's travel information.
Once I login and go to the page that displays a list of travel cards, I need to click on the View journey history link.
So here is the problem: the View journey history link only appears on the page once a Javascript script loads (I'm not too sure which). When I run my crawling script and I print this page, I can view the View journey history link (because it loads the javascript on the browser). However, when I try to crawl this page to find this link, it doesn't find it. My assumption is that this PHP library does not have a facility to run javascript (a browser-side language) on the backend.
How can I return the page html AFTER all javascript scripts have loaded and processed?
I'm using Goutte to crawl. This library uses Symfony BrowserKit which is supposed to simulate the behavior of a web browser, it would be good to know if it has a facility to process javascript before returning the html.
I'm open to any type of solution, meaning the use of different libraries, or even a different programming language.
Thanks in advance.
I've custom curl package for Laravel.
After login, you need to monitor the requests closely[use Google Chrome's Network tab.].
there are couple of scenarios.
1) website is making ajax request to some other url. You need to catch that url and send ajax request to that url to get data.
2) website is using javascript to render page data. In this case data will be already embedded in page source[js code]. You need to use regex to extract data from the page.
I only can this much of help without analysing calls, page source.
BrowserKit and PHP alone don't have the ability to execute JavaScript. There's a few options out there though; you could use something like Selenium and WebDriver or PhatomJS and automate things using something like Codeception (which is actually a testing library but could be used for scraping):
http://codeception.com/docs/modules/WebDriver
The disadvantage here is that this approach is quite slow and may not be compatible with whatever hardware you're running your scripts on (i.e. a web server with no GUI or browser).
Another approach would be to use ChromeDriver which is a bit quicker and more lightweight than Selenium and WebDriver. You can then automate all of this using Laravel Dusk (again, another testing library but nicely suited for this sort of thing):
https://laravel.com/docs/master/dusk
I am creating a Facebook application in the PHP SDK using the Graph API and I need to have a page to invite my friends to the application. Are there any methods in PHP to do the same?
I have seen the JavaScript method for this, but it doesn't match with my requirement (I need it as a page other than the JavaScript popup).
Read the documentation. If you do not use the JavaScript method, see the Direct URL Example paragraph.
I want to develop a Facebook application which shows the data from database from my own server.
I have found one question here : Can you use your own database for Facebook applications?
But like above question I don't want to use iFrame to show my content on Facebook application.
Any solution for this as, I am new to Facebook application development.
Edit:
Simplified version: I have a page in my server which generate xml feed of the product. So can I read this xml feed url in facebook Application?
Almost all applications use an iframe to display the actual app, I don't think you'll be able to avoid it. What you put into that iframe however is entirely yours. It runs from your server, and so can use whatever back end you prefer.
Why don'T you want to use iFrame? FBML & Iframes are only ways you can show your content with !
I am developing a facebook application that fetches the newsfeed of the logged in users and renders it. Currently, I am using iframe and I use PHP SDK to call the Graph API to fetch the posts and render them (generate on server side via PHP). To emulate the facbeook like look and feel, I mimicked their styles on which I am somewhat successful but not very much.
I am wondering is there a way in Facebook API to do the same for me? I read about the FBML but there is a deprecation warning along with a notice that they are gradually moving things towards their Javascript SDK.
Any ideas?
Well, you are narrowed to what XFBML (The Javascript API) offers you.
I had the same problem a while ago and this site saved me - http://devtacular.com/articles/bkonrad/how-to-style-an-application-like-facebook/
There are some basic styles that are used by facebook.
Good luck.
Here's the deal: I have an fb app I wrote mostly for my own benefit. (you can play with it at http://apps.facebook.com/bicyclelog/log.php?uid=0 if you like...)
Anyway, the problem is this: Facebook lobotomizes Javascript. Google Maps is Javascript based. Therefore, I have to put the map in an iFrame. But FB puts restrictions on iFrames, so I basically have to open a new page to display the map.
What I'd really like to do, however, is have the map pop-up, instead. Ideally, it would look like FB's other dialogs...
Can anyone suggest an approach? I'm a good C & device driver coder, but my PHP skills are kind of at the cargo-cult stage....
You could put an fb:iframe inside of an FBJS Dialog, and have the src be pointed to a non-facebook-authenticated page on your server (using your callback address, not apps.facebook.com/blah) that renders the map.
This will probably give you the same problems you were having with just using an iframe but it is really the only option because of how FB mangles JavaScript.