https://developers.facebook.com/bugs/create
Frontend and Backend are two modules and so I created a second Bootstrap.php in my modules/backend folder, which looks like this:
-
class Backend_Bootstrap extends Zend_Application_Module_Bootstrap
-
{
-
public function _initAuth(){
-
$auth = Zend_Auth::getInstance();
-
$authStorage = new Zend_Auth_Storage_Session('Yourapp_Admin_Auth');
-
$auth->setStorage($authStorage);
-
}
-
}
This seems to be enough to make a backend login independent frmo the frontend, keeping frontend users from seeing my backend just because they're logged in.
Thanks to the ZF community for NOTHING.
Recently I was forced to work with Zend Framework. I didn't not anything about it and at the very beginning I had an essential question: how do you make certain values available in every controller? I had to call getLoginUrl from the Facebook Api for every page and I was convinced that it was unnecessary to do this in every controller. So I asked my question in a Zend Framework beginners forum. And I got the following, helpful and explaining answer:
"Layout"
If you don't believe it, take a look at this page
Searching for a Lightbox I stumbled upon ColorBox. I needed a Lightbox which was 100% customizable, and this plugin did not only meet my needs, it positively surprised me in every detail: high flexibility, thoughtful and useful functions, good documentation and helpful examples. In fact, I'd go so far as to call this plugin the most amazing I ever encountered, since it just has everything right. Awesome. My everlasting thanks to the creator.
I've googled "Facebook" and "Safari", because there seems to be a problem with Safari v. 5.1.5 and the Facebook PHP SDK: getUser doesn't seem to work. What I found was an article not entirely covering what I was looking for, but the first answer was just so very stupid, that I got angry even before realizing that no one else seems to have the same safari problems as me.
I needed weather data on a wordpress page and all the plugins I found were not flexible enough for my needs. Then I discovered by accident the google weather API, which was basically just what I needed, but unfortunately there doesn't seem to be an official documentation. Thankfully I discovered the Web-Spirit page (in german), which explains the whole thing thoroughly, including examples and a great function to call the google API. There is a problem when trying to get the weather for an austrian city, but the solution is pretty simple:
-
$wetter =website_wetter("", "Austria", "de", "Linz");
And it works!
Today I found out that the clearfix hack doesn't do so well with Facebook. To avoid scrollbars in a facebook tab:
-
body, html {
-
overflow:hidden;
-
}
and before the closing body tag:
-
<div id="fb-root"></div>
-
<script type="text/javascript" src="https://connect.facebook.net/de_DE/all.js"></script>
-
<script type="text/javascript">
-
-
FB.init({
-
appId : 'APP_ID',
-
status : true,
-
cookie : true,
-
xfbml : true,
-
oauth : true
-
});
-
-
$(document).ready( function(){
-
FB.Canvas.setSize({ height: $('body').height() });
-
FB.Canvas.scrollTo(0,0);
-
});
-
-
</script>
Problem:
Wenn ein User auf meine app kommt, möchte ich rausfinden, zu welchen Gruppen er gehört. Diese Info brauche ich für einen sehr speziellen Authentifikationsprozess bei dem nur Mitglieder einer bestimmten Gruppe bestimmte Inhalte der App sehen können.
Lösung:
Das ganze geht natürlich nicht ohne die Permissions des Users abzufragen. Man zwingt bittet den User zuerst, die Permission user_groups zu gewähren und anschließend kann man über die Facebook PHP Api ganz einfach die Groups abfragen! Hier der ganze Code:
-
require_once 'facebook.php';
-
-
$secret = "12345678901234567890123456789012"; //App Secret
-
$id = "123456789012345"; //App ID
-
-
'appId' => $id,
-
'secret' => $secret,
-
'cookie' => true
-
));
-
$fbData = $fb->getSignedRequest();
-
-
//if you don't have the user ID, this means your user hasn't given any permissions yet
-
if(!$fbData['user_id']){
-
//ask for permissions
-
$auth_url = "https://www.facebook.com/dialog/oauth?scope=user_groups&client_id=".$id."&redirect_uri=https://www.facebook.com/pages/PAGENAME/PAGEURL?sk=app_123456789012345";
-
}
-
-
//get an access token
-
$access_token = $fb->getAccessToken();
-
-
//get the groups
-
$res = $fb->api('/me/groups?access_token='.$access_token, 'GET');
-
-
//output
-
echo "Groups:<br>";
-
echo "<ul>";
-
foreach($res['data'] as $k => $group){
-
}
-
echo "</ul>";
Okay, this cost me a lot of time and nerves.
Todo:
Videos coming from vimeo, they must be played in jwplayer. There must be a preroll ad, the URL to this video ad contains a 10-digit random number, which is the reason why I cannot use a config.xml file but have to configure it inline. And, to make it just a bit harder, I was asked to use the javascript API instead of the <embed> tag.
Problem:
The documentation is... well, it's not good. There are plenty of good examples for the <embed> tag version, but close to none for the javascript API. Additionally I asked for help in the jwplayer forums and the result was a very uninterested, uninformed reply. The person seemed to have a hard time following my description, demanded a link to an implemented version, blamed my video ad url, and finally, when he understood my problem, this: "Go post in the OVA plugin forum". Let me point out that it took 3 days for this 'advice' to come forth...
Solution:
The OVA Plugin Forum was very helpful, the answers were quick and competent, within a short amount of time I managed to make it work. Here is a complete example script:
-
<div id="container">Loading...</div><script type="text/javascript">
-
jwplayer('container').setup({
-
'width': 500,
-
'height': 300,
-
'file': 'http://player.vimeo.com/external/123456.sd.mp4?s=858afaac8eebccc7acb544e998799a3d',
-
'skin': 'jwplayer/bekle.zip',
-
'plugins': {
-
'jwplayer/ova-jw.swf': {
-
'ads': {
-
'notice': { 'textStyle': 'smalltext' },
-
'filterOnLinearAdMimeTypes': false,
-
'schedule': [
-
{
-
'zone': '47',
-
'position': 'pre-roll',
-
'server': {
-
'type': 'direct',
-
'tag': 'http://www.adververdomain.de/video?[<?php echo rand(1000000000, 9999999999); ?>]'
-
}
-
},
-
{
-
'zone': '48',
-
'position': 'auto:bottom',
-
'width': 320,
-
'height': 80,
-
'startTime': '00:00:02',
-
'duration': '5'
-
}
-
]
-
}
-
},
-
'sharing-3': {
-
'link': '<?php echo $_SERVER['PHP_SELF']; ?>'
-
},
-
'fbit-1': {
-
'link': '<?php echo $_SERVER['PHP_SELF']; ?>'
-
},
-
'plugins': {
-
'gapro-2': {}
-
}
-
},
-
'modes': [
-
{type: 'flash', src: 'jwplayer/player.swf'},
-
{type: 'html5'},
-
{type: 'download'}
-
]
-
});
-
</script>
Thanks again for competent and friendly help in the OVA Plugin forum!
If $.ajax and $.post don't return any value only in Safari, it might be a path problem.
http://www.domain.de/path/to/ajax.php - didn't work with Safari
/path/to/ajax.php - works with Safari as well!