Script follower exchange (Generator) [closed]

-2

I have the following code in php done by abraham in case it would be this system :

<?php
require_once './modules/Config.php';
require_once './libs/OAuth.php';
require_once './libs/twitteroauth.php';

// 1. to handle logout request
if(isset($_GET['logout'])){
  //unset the session
  session_unset();
  // redirect to same page to remove url paramters
  $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}


// 2. if user session not enabled get the login url
if(!isset($_SESSION['data']) && !isset($_GET['oauth_token'])) {
  // create a new twitter connection object
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
  // get the token from connection object
  $request_token = $connection->getRequestToken(OAUTH_CALLBACK); 
  // if request_token exists then get the token and secret and store in the session
  if($request_token){
    $token = $request_token['oauth_token'];
    $_SESSION['request_token'] = $token ;
    $_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
    // get the login url from getauthorizeurl method
    $login_url = $connection->getAuthorizeURL($token);
  }
}

// 3. if its a callback url
if(isset($_GET['oauth_token'])){
  // create a new twitter connection object with request token
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['request_token'], $_SESSION['request_token_secret']);
  // get the access token from getAccesToken method
  $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
  if($access_token){  
    // create another connection object with access token
    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
    // set the parameters array with attributes include_entities false
    $params =array('include_entities'=>'false');
    // get the data
    $data = $connection->get('account/verify_credentials',$params);
    if($data){
      // store the data in the session
      $_SESSION['data']=$data;
      // redirect to same page to remove url parameters
      //$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
      //header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
      header('Location:' . URL_BASE . '/dashboard');
    }
  }
}
?>

You're logging in straight away, I've been able to recover some information from my profile, etc., I wonder if I can use this code to do a follower exchange system? If so, what should I study?

    
asked by anonymous 21.05.2017 / 23:17

1 answer

1

You can create a banco de dados , save all $data->screen_name to a tabela any, use javascript with ajax for users to follow themselves.

STUDY MORE HERE

It's complicated, but it's possible, remember, this is against Twitter's usage rules.

If I'm not mistaken you should study REST APIs and find out a form (function in php or javascript ) to make each $data->id_str make the changes. If possible post the code already done.

    
22.05.2017 / 13:44