sfFacebookConnectPlugin: Authentication problem - authentication

I try to get the sfFacebookConnectPlugin to run by following the tutorial on the symfony homepage.
Everything seems well configured. But when I try to login with sfFacebookConnectAuth/signin.
I get the form error "The username and/or password is invalid.".
I even don't know where to start with the debugging.
First Step could be to find out the right Application-Settings on the Facebook-Side (e.g. Post-Authorize Callback URL, Connect-URL or Canvas Callback URL)
I use symfony 1.4.5 doctrine with sfGuardDoctrinePlugin (on a live host with subdomain.)
Thx for your help.

I found that page: http://burgiblog.com/2009/09/18/developing-facebook-applications-with-symfony/ now it works, I changed three things after reading the tutorial:
modules/sfFacebookConnectAuth/config/security.yml: Use "false" instead of "off"
I added "callback_url" in apps/frontend/config/app.yml
And I used the facebook action in the tutorial
I need to find out, what the problem exactly was. And I need to enhance some things to the plugin. E.g. saving the user data to my profile class etc. (Now I saves a cryptic username instead of the right FB username.)

It says on the plugin page that this plugin is only supported/stable up to Symfony 1.2. Might make sense to email the plugin author directly regarding 1.4 compatibility.

I'm having some problems with sfFacebookConnectPlugin. I tried replicating the simple example from http://burgiblog.com/2009/09/18/developing-facebook-applications-with-symfony/ . And calling the index page, I get redirected to the facebook authentication page but after logging in, I do not get redirected back. I stay logged into facebook only. What am I doing wrong?
Thanks.
This is my code:
[/frontend/config/app.yml]
# default values
all:
facebook:
api_key: xxx
api_secret: xxx
api_id: xxx
callback_url: 'http://localhost'
redirect_after_connect: false
redirect_after_connect_url: ''
connect_signin_url: 'sfFacebookConnectAuth/signin'
app_url: '/my-app'
guard_adapter: ~
js_framework: none # none, jQuery or prototype.
# It is highly recommended to use a js framework if you want a correct experience in IE
sf_guard_plugin:
profile_class: sfGuardUserProfile
profile_field_name: user_id
profile_facebook_uid_name: facebook_uid # WARNING this column must be of type bigint ! 100000398093902 is a valid uid for example !
profile_email_name: email
profile_email_hash_name: email_hash
facebook_connect:
load_routing: true
user_permissions: []
[layout.php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<?php use_helper('sfFacebookConnect') ?>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<?php echo $sf_content ?>
<?php include_bottom_facebook_connect_script(); ?>
</body>
</html>
[actions.class.php]
<?php
/**
* facebook actions.
*
* #package
* #subpackage facebook
* #author Your name here
* #version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
*/
class homeActions extends sfActions
{
/**
* Executes index action
*
* #param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
sfFacebook::requireLogin();
//get the user object
$user = $this->getUser();
// facebook user id
$this->fb_uid = $user->getCurrentFacebookUid();
// get or create user based on fb_uid
$fb_user = sfFacebook::getOrCreateUserByFacebookUid($this->fb_uid);
}
}
[indexSuccess.php]
<?php if ($sf_user->isFacebookConnected()): ?>
<fb:serverfbml style="width: 740px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form target="_top" action="[where to redirect after invite]" method="post" type="[name of your app]" content="[text the user will receive]<fb:req-choice url="http://apps.facebook.com/[your app]/" label="Accept!" " image="" invite="true">
<fb:multi-friend-selector cols="4" actiontext="[some text above the invite form]" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
<?php else: ?>
<p>Ooops?</p>
<br />
<?php endif; ?>

Related

Coovachilli Captive Portal examples (without commercial solution)

Blockquote
I am trying to setup a captive portal for POC purpose, I have read all official docs from Coovachilli, and my freeRadius, Coovachilli and splash page are deployed. After I connect my open wifi SSID the splash page can popup, I design it as simple as possible the username and password are hardcoded but a button of Connect is ready for clicking to trigger chilliController.logon(username, password)... from here I can't see any feedback but a timeout kind of error. There is no error from javascript of my splash page, is there any example (no commercial solutinos please) I can learn to fix the issue I have? I feel I am in a lost land that I suspect if any conceptual idea was wrong in my mind. Any lucks?
Coovachilli Config:
#
# Sample Coova-Chilli configuration file modified by gremaudpi
#
config chilli
option interval 3600
option swapoctets 1
option debug 1
option debugfacility 3
######## TUN and DHCP Parameters ########
option tundev 'tun0'
option dhcpif 'br-wopen'
option net 10.10.100.0/24
option lease 600
option dns2 8.8.8.8
option dns1 8.8.4.4
option ipup '/etc/chilli/up.sh'
option ipdown '/etc/chilli/down.sh'
######## Radius parameters ########
option radiusserver1 '10.10.50.93'
option radiusserver2 ''
option radiusauthport 1812
option radiussecret 'testing123'
option radiusnasid 'nas01'
option ssid 'ZWLS-OPEN'
######## Universal access method (UAM) parameters ########
option uamlisten 10.10.100.1
option uamserver 'http://10.10.50.93:8011/www/LOGIN.html'
# option wwwdir "/etc/chilli/www"
option uamport 3990
option uamsecret 'testing123'
option uamallowed 'www.yahoo.com,10.10.50.1,10.10.60.1,10.10.50.93'
option uamdomain ''
option uamanydns 1
option uamaliasname 'login'
option nouamsuccess 1
Splash Page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Coova Portal</title>
<script type="text/javascript" src="ChilliLibrary.js"></script>
<script>
chilliController.host = '10.10.100.1';
chilliController.port = '3990';
chilliController.interval = 60 ; // Default is 30 seconds
// then define event handler functions
chilliController.onError = handleErrors;
chilliController.onUpdate = updateUI ;
// when the reply is ready, this handler function is called
function updateUI( cmd ) {
alert ( 'You called the method' + cmd +
'\n Your current state is =' + chilliController.clientState ) ;
}
// If an error occurs, this handler will be called instead
function handleErrors ( code ) {
alert ( 'The last contact with the Controller failed. Error code =' + code );
}
// finally, get current state
chilliController.refresh();
function go() {
// If you use non standard configuration, define your configuration
//chilliController.host = document.getElementById("host").value ; // Default is 192.168.182.1
//chilliController.port = document.getElementById("port").value ; // Default is 3990
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
console.log(username, password);
console.log(chilliController.host);
console.log(chilliController.port);
chilliController.logon(username,password);
}
</script>
</head>
<body>
<p>Click</p>
<label for="host">Host:</label>
<input type="text" id="host" name="host" value="10.10.100.1"><br>
<label for="port">Port:</label>
<input type="text" id="port" name="port" value="3990"><br>
<label for="username">Username:</label>
<input type="text" id="username" name="username" value="dummy"><br>
<label for="password">Password:</label>
<input type="text" id="password" name="password" value="dummy123">
<br>
<a class="TSlink" href="javascript:go()">Go</a>
</body>
</html>
One symptoms is that after connect with host spot open wifi, if open a browser and type the url: http://10.10.100.1:3990/json/status?callback=chilliJSON.reply&0.430314783392284
the browser is redirect to my splash page (http://10.10.50.93:8011/www/LOGIN.html)
The Chilli debug log:
chilli[5946]: dhcp_receive_ip(3760): Address found
chilli[5946]: dhcp_receive_ip(3760): Address found
chilli[6005]: redir_getreq(2150): The path: json/logon
chilli[6005]: redir_getreq(2505): -->> Setting userurl=[http://10.10.100.1:3990/json/logon?username=dummy&chapchallenge=q1w2e3r4&chappassword=cae9d6bc04f3deaa&lang=EN]
chilli[6005]: redir_main(4207): redir_accept: Original request host=10.10.100.1:3990
chilli[6005]: redir_wispr2_reply(994):
chilli[5946]: dhcp_receive_ip(3760): Address found
chilli[5946]: chilli_handle_signal(386): caught 18 via selfpipe
chilli[5946]: _sigchld(316): child 6005 terminated
chilli[5946]: child_remove_pid(138): Freed child process 6005 [[redir]]
chilli[5946]: dhcp_receive_ip(3760): Address found
chilli[5946]: dhcp_receive_ip(3760): Address found
I can not check the "status" at all, what's the problem here?

Laravel - Api request

I have a website build with Laravel 4.2 and a controller that are accessible only to logged user:
Route::group(['prefix' => 'pannello-utente', 'before' => 'auth'], function ()
{
Route::get('elenco-animali/{nome?}', ['uses' => 'PazientiController#index']);
Route::get('download/{cartella}/{file}', ['uses' => 'PazientiController#download']);
});
the auth method request user to insert email and password.
In the PazientiController I have the __construct method that perform some queries that retrieve a code and use it in the other method:
public function __construct()
{
$this->current_user = Auth::user();
//Recupero il codice cliente salvato nel profilo utente
$this->codice = User::find($this->current_user->id)->first()->profile->codice_cliente;
}
This code is saved only in the database and, at the moment, no other application have it so I need to execute that query every time.
I need that, now via curl then via smartphone app, the user can access to the method, so I need users to log in before:
curl --user chri788#gmail.com:adminadmin localhost:8888/*****/public/pannello-utente/elenco-animali
But I get this:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="1;url=http://localhost:8888/*****/public/login" />
<title>Redirecting to http://localhost:8888/*****/public/login</title>
</head>
<body>
Redirecting to http://localhost:8888/****/public/login.
</body>
</html>
How can I access to that controller?
The --user flag for curl triggers HTTP Basic Authentication. Laravel supports this, but not with the auth filter - it needs the auth.basic filter.
You can write a custom filter that checks both auth and auth.basic, or you can provide a separate set of routes (maybe prefixed with api) that uses the alternate filter.
http://laravel.com/docs/4.2/security#http-basic-authentication

Getting posts from google plus page

I would like to get content (posts) from a google+ page and post it to my website, as a feed. Is there any info how?
I read that current API does not allow that, but those topics were from the last year.
Thanks.
You can perform activities.list, without having to authenticate, by passing your "simple" key from the API console for a project created that has the Google+ service turned on. Access to the API calls is restricted to the authorized origins you set up in your project.
After you create the project, in the section "Simple API Access" there is an API key. Build your client with this key, your client id, and client secret:
<?
$client = new Google_Client();
$client->setDeveloperKey("YOUR_API_KEY");
$plus = new Google_PlusService($client);
$activities = $plus->activities->listActivities("+GooglePlusDevelopers", "public");
?>
<html><body><pre><? echo print_r($activities);?></pre></body></html>
A final note, make sure you use the latest Google+ PHP client.
After some time I found it.
http://code.google.com/p/google-plus-php-starter/
and this
https://developers.google.com/+/api/latest/activities/list
The only problem is that you need to log into your google app to do this. Any sugggestions would be apprecited.
Updating the correct answer, the class name has changed to Google_Service_Plus
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ .'/vendor/google/apiclient/src');
require_once __DIR__.'/vendor/autoload.php';
$client = new Google_Client();
$client->setDeveloperKey("YOUR_API_KEY");
$plus = new Google_Service_Plus($client);
$activities = $plus->activities->listActivities("+GooglePlusDevelopers", "public");
?>
$items = $activities->getItems();
foreach($items as $item) {
$object = $item->getObject();
?>
<div class="gpost">
<p><?php echo $object->getContent(); ?></p>
Read more
</div>
<?php } ?>

Using Google Analytics on a 503 page

I'm using varnish to cache our pages. When we get a 503 -- which happens a little too often -- I'd like to put some sort of page tracking on there. I'd like to place the GA code in there. I can't seem to find any instance of anyone else doing this. Has anyone done this? Is there some sort of T&C violation in doing this?
For Varnish you can use vcl_error to include your own responses (that have the Google Analytics code).
Edit: I have not tested any of these. They are just examples.
An example:
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
if (obj.status == 503) {
synthetic {"
<html>
<head>
<title></title>
</head>
<body>
<h1>Error</h1>
<p>Something</p>
<!-- ANALYTICS CODE -->
</body>
</html>
"};
return(deliver);
}
}
Alternatively you can add your own pages from the file system by using vmod (which is included as standard with version 3.*+).
# Add this to the top of your config
import std;
# vcl_error
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
if (obj.status == 503) {
set obj.http.error503 = std.fileread("/path/to/errors/503.html");
synthetic obj.http.error503;
return(deliver);
}
}

Automatically grab file path

Everyone i am looking for a way to automatically upload a file but skip the browse and choose file process.
So i set the location of the file somehow via the form and the client just has to click submit and it will automatcially upload the file from the path i have set. skipping the browse for file process.
I would like to intergrate it into the following undesigns S3 Class
http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation
<?php
S3::setAuth(awsAccessKey, awsSecretKey);
$bucket = "upload-bucket";
$path = "myfiles/"; // Can be empty ""
$lifetime = 3600; // Period for which the parameters are valid
$maxFileSize = (1024 * 1024 * 50); // 50 MB
$metaHeaders = array("uid" => 123);
$requestHeaders = array(
"Content-Type" => "application/octet-stream",
"Content-Disposition" => 'attachment; filename=${filename}'
);
$params = S3::getHttpUploadPostParams(
$bucket,
$path,
S3::ACL_PUBLIC_READ,
$lifetime,
$maxFileSize,
201, // Or a URL to redirect to on success
$metaHeaders,
$requestHeaders,
false // False since we're not using flash
);
$uploadURL = "https://{$bucket}.s3.amazonaws.com/";
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>S3 Form Upload</title>
</head>
<body>
<form method="post" action="<?php echo $uploadURL; ?>" enctype="multipart/form-data">
<?php
foreach ($params as $p => $v)
echo " <input type=\"hidden\" name=\"{$p}\" value=\"{$v}\" />\n";
?>
<input type="file" name="file" /> <input type="submit" value="Upload" />
</form>
</body>
</html>
at what point does it grab the file path ?
is it grabbing it out of the name here
can i do something with $_FILES ???
Can someone please give me a point on where to start i would really appriciate this.
thanks
You'll have to specify the tools of the trade. A common html form has no such functionality.
You can try value="c:\somefile.ext" but many browsers will not accept this.