Alligatoras
Administrator
- Mar 31, 2016
- 2,570
- 12
- 2,857
- 381
Does anyone know if there a way to connect the facebook api with teamspeak?
Little problem is: if the name have more than x characters, you have to cut somwhere in the name. :xthank you
what i am thinking is to make a script that a user will login to teamspeak with their facebook name.
Little problem is: if the name have more than x characters, you have to cut somwhere in the name. :x
Does anyone know if there a way to connect the facebook api with teamspeak?
i got facebook api, but i have never used it before, or at least try to make my own stuff with itITs not difficult. u need app facebook ,if u have project PM me i work on facebook api + php and ts3
i got facebook api, but i have never used it before, or at least try to make my own stuff with it
I don't have any project generally, i just have a page that when you click the connect button the user connect to a ts server. nothing else.
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require_once( 'autoload.php' );
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication( 'APP ID','APP SECRET' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('Link to this file.' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfullname = $graphObject->getProperty('name');
$femail = $graphObject->getProperty('email');
header("Location: index.php".$extra);
} else {
$loginUrl = $helper->getLoginUrl(array('req_perms' => 'email'));
header("Location: ".$loginUrl);
}
?>