Just trying to help whoever else may read this forum.yes. Sorry perhaps I should have to do only one thread?
Well... If your application knows that the facebook login was a success, and is somehow notified about it...after logging in via social networks, users are redirected to a PHP page that gets the data from the profile ... Then?
yes! but how?You could use the API to create a temporary hotspot username and password (also set the account to remove itself on log out), and then redirect the user to the router with the generated username and password in the URL.
$addRequest = new RouterOS\Request('/ip hotspot user add');
$addRequest
//->setArgument('profile', 'facebook') //Maybe?
//The line below might be needed so that the router and facebook login expire together.
//Otherwise, the router login will persist even after the facebook login has expired.
//->setArgument('limit-uptime', ($facebookExpiresIn - time()) . 's')
->setArgument('name', 'FACEBOOK_' . $facebookUserID) //The prefix is in case you have non-facebook users on the router.
->setArgument('password', $facebookAccessToken);
$client($addRequest);
$routerQuery = http_build_query(
array(
//'dst' => $_SEVER['HTTP_REFERER'], //Optional.
'username' => 'FACEBOOK_' . $facebookUserID,
'password' => $facebookAccessToken
)
);
header('Location: http://192.168.5.1/login?' . $routerQuery);
/ip hotspot user remove $userIf you have non-facebook users on the same router, you'll want to create a separate profile for facebook users, and only add the above to that profile.
header('Location: http://192.168.5.1/login?' . $routerQuery);
That's what the header() call does - it makes the client device send a separate HTTP request to the router. The router will "unlock" the client device if the username and password are correct... Which they are certain to be in this case, since you just generated them earlier in the same file.how can I "unlock" him?
ok so since the router can't interpret php I imagine that there is some javascript that "unlocks" the client device... how?The router will "unlock" the client device
There's no programming code of any sort. You can't login/unlock a user remotely in any fashion. Not with PHP, not with JavaScript, not with anything else.ok so since the router can't interpret php I imagine that there is some javascript that "unlocks" the client device... how?The router will "unlock" the client device
You should be able to configure RouterOS so that it appends the originally requested URL to the URL of the PHP page (the one which will in turn request login from Facebook). That URL can in turn be placed in the "dst" query parameter, near the end of the PHP code snippet above (see the commented line).ok if I have understood is the http request which gives users access to ...
So I have a problem with this because after the http request I get redirected to the captive portal page
$addRequest = new RouterOS\Request('/ip hotspot user add'); $addRequest ->setArgument('name', $user) ->setArgument('password', $psw); $client($addRequest);3 - Which http request for logging user in?
$routerQuery = http_build_query(
array(
'username' => $user,
'password' => $psw
)
);
header('Location: http://192.168.5.1/login?'.$routerQuery);
Can you elaborate more on that? Any error messages on screen or in PHP/RouterOS logs? Can you see the username added in the router?Doesn't work
> sigh <What is "login" in the URL?
$addRequest = new RouterOS\Request('/ip hotspot user add');
$addRequest
//->setArgument('profile', 'facebook') //Maybe?
//The line below might be needed so that the router and facebook login expire together.
//Otherwise, the router login will persist even after the facebook login has expired.
//->setArgument('limit-uptime', ($facebookExpiresIn - time()) . 's')
->setArgument('name', 'FACEBOOK_' . $facebookUserID) //The prefix is in case you have non-facebook users on the router.
->setArgument('password', $facebookAccessToken);
$client($addRequest);
$routerQuery = http_build_query(
array(
//'dst' => $_SEVER['HTTP_REFERER'], //Optional.
'username' => 'FACEBOOK_' . $facebookUserID,
'password' => $facebookAccessToken
)
);
header('Location: http://192.168.5.1/login?' . $routerQuery);
$client($addRequest);
$client = new RouterOS\Client('2.34.107.153', 'admin', 'password');
<?php
include('config.php');
include('hybridauth/Hybrid/Auth.php');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
try {$client = new RouterOS\Client('2.34.107.153', 'admin', 'password');}
catch (Exception $e) { ?> <div>Unable to connect to RouterOS.</div> <?php }
$addRequest = new RouterOS\Request('/ip hotspot user add');
$addRequest
->setArgument('name', $name)
->setArgument('password', $password);
$client($addRequest);
$routerQuery = http_build_query(
array(
'username' => $name,
'password' => $password
)
);
header("location: http://172.16.0.1/login?".$routerQuery);
?>
$client($addRequest);
$client->sendSync($addRequest);
Fatal error: Call to a member function sendSync() on a non-objectTry to replacewithCode: Select all$client($addRequest);
Code: Select all$client->sendSync($addRequest);
$addRequest = new RouterOS\Request('/ip hotspot user add');
$addRequest
->setArgument('name', $name)
->setArgument('password', $password);
$client($addRequest);
$routerQuery = http_build_query(
array(
'username' => $name,
'password' => $password
)
);
header("location: http://172.16.0.1/login?".$routerQuery);
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
include 'config.php';
include 'hybridauth/Hybrid/Auth.php';
try {
$client = new RouterOS\Client('2.34.107.153', 'admin', 'password');
$addRequest = new RouterOS\Request('/ip hotspot user add');
$addRequest
->setArgument('name', $name)
->setArgument('password', $password);
$client($addRequest);
$routerQuery = http_build_query(
array(
'username' => $name,
'password' => $password
)
);
header("location: http://172.16.0.1/login?".$routerQuery);
}
catch (Exception $e) {
?> <div>Unable to connect to RouterOS.</div> <?php
}
just access the same web server (the same PHP file, located at the same place) from a different PC?
172.16.0.1
but I don't need to do this . this is a temporary Situation just to tryyRouterBOARD
$client = new RouterOS\Client($_SERVER['REMOTE_ADDR'], 'admin', 'XXXXX');
<tr>
<th>Time</th>
<th>Topics</th>
<th>Message</th>
</tr>
ini_set('display_errors', 'On');
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>RouterOS log</title>
<style type="text/css">
table, td, th {border: 1px solid black;}
td span {outline: 1px dotted black;}
</style>
</head>
<body>
<?php
try {
$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');
?><table>
<thead>
<tr>
<th>Time</th>
<th>Topics</th>
<th>Message</th>
</tr>
</thead>
<tbody><?php
$logEntries = $client->sendSync(
new RouterOS\Request('/log print')
)->getAllOfType(RouterOS\Response::TYPE_DATA);
foreach ($logEntries as $entry) {
?>
<tr>
<td><?php echo $entry('time'); ?></td>
<td><?php
$topics = explode(',', $entry('topics'));
foreach ($topics as $topic) {
?>
<span><?php echo $topic; ?></span><?php
}
?>
</td>
<td><?php echo $entry('message'); ?></td>
</tr><?php } ?>
</tbody>
</table>
<?php }
} catch (Exception $e) {
?><div>Unable to retrieve logs.</div>
<?php
}
?>
</body>
</html>
I don't know. Could be anything between the MikroTik and your web host, including the modem fault/"protection", an ISP level fault/"protection", or a web host level fault/"protection", or any cables in between any one of those.Then something "physical", not "logical" ... I mean, hardware or cables?
Registered which domain with which DNS management? Actually, never mind... It shouldn't be an issue, since you're contacting the router by its IP, and the router doesn't care what IP you're accessing it from. Besides, it's the connection is established, it means any such sort of obstacles are already avoided.I just registered the domain with dns management. Could this got to do?