I am a beginner in Joomla, I want to integrate Facebook login with my website (using Joomla 3.0), I want to know how to store the user info into my database after receiving them from facebook. Any suggestion?
Try this,
If you are using FB SDK for PHP
$path = realpath('.');
require_once($path."/facebook/fbmain.php");
$user = $facebook->getUser();
// print_r($user);
// echo "user<br/>";
// print_r($userInfo);
// echo "<br/>Info<br/>";
// print_r($fqlResult);
// foreach($fqlResult as $key=>$value){
// print_r($value);
// echo '<br>';
// }
// exit;
if ($user){
$fname = $userInfo['first_name'];
$last_name = $userInfo['last_name'];
$username = $userInfo['id'];
$dob = date("d-m-Y",strtotime($userInfo['birthday']));
foreach($fqlResult as $key=>$value);
$user_email = $value['email'];
$profile_image = $value['pic_square'];
$sex = $value['sex'];
$city = $value['hometown_location']['city'];
$state = $value['hometown_location']['state'];
$country = $value['hometown_location']['country'];
$zip = $value['hometown_location']['zip'];
//Then simply call model and write save db query.
$model = $this->getModel('Registration', 'UsersModel');
}
You want to make a FB authentication plugin and then have that pass off the data to the Joomla user plugin if possible. If you want to use a different user table you would need to make your own user plugin as well. Joomla auth first authenticates (authentication plugin), then authorsises, then logs in (user plugin)
Related
I am trying to make a PayPal transaction in my page. I have the following fields defined:
firstname
lastname
address
email
amount
When I click to proceed to payment it redirects my browser to PayPal correctly. Afterwards I am able to log in using the test account and make a test payment. The problem is that when I call print_r to display the return_url to check the data that has been passed, I noticed that my input textbox wasn't there.
Here is the code that posts to PayPal:
$firstname = $this->input->post('firstname');
$lastname = $this->input->post('lastname');
$address = $this->input->post('address');
$email = $this->input->post('email');
$config['business'] = 'test#test.com';
$config['return'] = 'http://localhost/test/payment/return_details/';
$config['cancel_return'] = 'http://localhost/test/payment/create-job-listing/';
$config['production'] = FALSE; //Its false by default and will use sandbox
$config["first_name"] = 'asdasd';
$config["last_name"] = 'asasas';
$config['address1'] = 'new york';
$this->load->library('paypal',$config);
$this->paypal->add('Amount',0.1);
$this->paypal->pay(); //Proccess the payment
Can someone help me figure this out?
In your return_url put the code:
<?php
echo "<pre>";
$data = file_get_contents('php://input'); //this fetches the raw input stream
$info = explode('&',$data);
echo "<pre>";
print_r($info);
?>
//Information sent by paypal is in the input stream and this code fetches the input!!
Good evening, I have this code but I need to know if this actually logged but do not make it, that I'm wrong? this scritp not show me any errors: (
$userDetails = array('foo' => 'bar');
$storage = new Zend_Auth_Storage_Session();
// set sorage for Zend_Auth
Zend_Auth::getInstance()->setStorage($storage);
// write data to the storage
Zend_Auth::getInstance()->getStorage()->write($userDetails);
// read data from storage
$c = Zend_Auth::getInstance()->getStorage()->read();
$result = $c->authenticate($userDetails);
echo $this->view->form = var_dump($result);
if (!$result->isValid()){
var_dump('FAILURE');
}else{
$this->_helper->redirector('index','index');
}
You could check session in Zend by,
if (Zend_Auth::getInstance()->hasIdentity()) {
// do user session action
} else {
// redirect to login page
}
To get user info try,
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
what i want to achieve is, user login in my wordpress website and also login on vanilla forum, i have installed jsconnect plugin in vanilla forum, and using the php's jsconnect library from following location jsConnectPHP
Here is my code:
require_once('functions.jsconnect.php');
$clientID = "1501569466";
$secret = "xxxxxxxxxxxxxxxxxxxxxx";
$userD = array();
if( isset($_POST['log']) ){
$data = array();
$data['user_login'] = $_POST['u_user'];
$data['user_password'] = $_POST['u_pass'];
$data['remember'] = TRUE;
$user = wp_signon($data, FALSE);
if(!is_wp_error($user)){
$userD['uniqueid'] = $user->ID;
$userD['name'] = $user->user_login;
$userD['email'] = $user->user_email;
$userD['photourl'] = '';
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
$redirect = "http://localhost/vanilla/entry/jsconnect?client_id={$clientID}";
echo "<script>document.location.href='".$redirect."';</script>";
}
}
when the user login on wordpress i redirect it to jsconnect url in vanilla where i just found only a progress image, and can't figure out where is the problem..
jsconnect authentication url expects jsonp array like the following:
test({"email":"test#test.com",
"name":"testuser",
"photourl":"",
"uniqueid":1234,
"client_id":"12345678",
"signature":"XXXX"})
You authorization url you specify inside jsconnect should see this output to process further. In fact I am stuck at that point. I could see vanilla forum when loaded gets this input but no login happens.
My code:
<?php
if(isset($_GET['login']) && isset($_GET['login']) && isset($_GET['password'])){
$_login_url = "http://testing.wialon.com/wialon/ajax.html?svc=core/login¶ms={user:%s,password:%s}";
$login = $_GET['login'];
$password = $_GET['password'];
$handle = fopen(sprintf($_login_url, $login, $password), "r");
$line = fgets($handle);
fclose($handle);
$responce = explode(",",$line);
if(count($responce) < 2) {
echo "Invalid user or password";
} else {
$sessid = explode(":",$responce[1]);
$lastid = str_replace("\"","",$sessid[1]);
echo "http://testing.wialon.com/index.html?sid=".$lastid."";
}
}
?>
when I access this script with the server hosting the script everything works perfectly, The sessions are generated with my IP address.
But when I access it with another computer any user trying to login the script generates session using the servers IP address. can I send the request with the users IP address?
No, you cannot send the request with the users IP address.
However, you might be able to indicate that the request is being performed on behalf of another IP by using the HTTP_X_FORWARDED_FOR request header or similar, but without looking at their documentations (which doesn't seem to be publicly available) I can't be sure of it. You'll need to ask 'em.
This is an old thread but, let me put in my two cents. There are two new wialon athentication methods Token login and by passing the athorization hash . the second method is best suited for maintaining session across servers.
http://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/core/create_auth_hash
http://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/token/token
//get the Token from here http://hosting.wialon.com/login.html?client_id=wialon&access_type=-1&activation_time=0&duration=0&flags=1
// You should have your existing username from wialon with SDK access
$params = "{'token':'$token','operateAs','$username'}";
$baseurl = "http://hst-api.wialon.com/wialon/ajax.html";
$url = "$baseurl?params=".urlencode($params)."&svc=token/login";
$o = json_decode(file_get_contents($url),true);
$sid = $o['eid'];
<?php
require_once ("RestHandler.php");
$param="";
if(isset($_GET["param"]))
{
$param = $_GET["param"];
}
//var_dump($param);
if(strpos($param,'studentlogin')!==false) // for handling student login requests
{
$param = explode("-",$param);
$param = explode(",",$param[1]);
$stuID = explode("=",$param[0]);
$stuID = $stuID[1];
$pass = explode("=",$param[1]);
$pass = $pass[1];
$restHandler = new RestHandler();
$restHandler->checkStudentLogin($stuID,$pass);
}
else if(strpos($param,'teacherslist')!==false)
{
$restHandler = new RestHandler();
$restHandler->getTeachersList();
}
else if(strpos($param,'questionslist')!==false)
{
$restHandler = new RestHandler();
$restHandler->getQuestionsList();
}
?>
This is the URL to get vale.
If I call this then it works properly.
http://localhost/xampp/api/index.php?param=questionslist
Response in JSON
[{"questionID":"1","statement":"How are you?"},{"questionID":"2","statement":"What is your name?"}]
However for log in (studentlogin) I can't figure out how to pass the value.
To pass array in url do like this
http://localhost/path/index.php?param[]=param1¶m[]=param2¶m[key]=param3&name=name etc.
To pass values to via url, use whole details when click the link(submit or anything).
for example in your category:
try this:
http://localhost/xampp/api/index.php?param=text-text=[studentID],text=[password]
remove [studentID] with ID and [password] with PASSWORD.
the student details was send via url. this may work.