<?php require_once __DIR__ . '/controller/config.php'; require_once __DIR__ . '/controller/Twitterlogin.php'; $twitterLogin = new MyApp\TwitterLogin(); use Abraham\TwitterOAuth\TwitterOAuth; if ($twitterLogin->isLoggedIn()) { $me = $_SESSION['me']; MyApp\Token::create(); } else { header('Location: http://' . $_SERVER['HTTP_HOST'] . '/devAid-v1.2/index.php'); exit; } $screen_name = $me->tw_screen_name; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $me->tw_access_token, $me->tw_access_token_secret); // ユーザIDでフォローする $connection->post('friendships/create', ['screen_name' => 'hatebu']); // ユーザ名でユーザ情報を取得 $user_info = $connection->get('users/show', ['screen_name' => $screen_name]); $user_name = $user_info->name; $user_id = $user_info->screen_name; $user_img = $user_info->profile_image_url_https; $user_follows = $user_info->friends_count; $user_followers = $user_info->followers_count; ?> <!DOCTYPE html> <html lang="en"> <head> <title>両思いったー</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/devAid-v1.2/index.php'); exit; } $screen_name = $me->tw_screen_name; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $me->tw_access_token, $me->tw_access_token_secret); // ユーザ名でユーザ情報を取得 $user_info = $connection->get('users/show', ['screen_name' => $screen_name]); $user_name = $user_info->name; $user_id = $user_info->screen_name; $user_img = $user_info->profile_image_url_https; $user_follows = $user_info->friends_count; $user_followers = $user_info->followers_count; // $my_id_str = $userinfo->id; if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { MyApp\Token::validate('token'); } catch (Exception $e) { echo $e->getMessage(); exit; } $register = new Myapp\Register(); $register->register($user_id, $connection); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>両思いったー</title> <!-- Meta --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">