質問編集履歴

1

mypage.phpのコードを記述しました。

2018/01/30 10:35

投稿

icecream
icecream

スコア7

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ### ヘディングのテキストWeb制作初心者です。
1
+ トWeb制作初心者です。
2
2
 
3
3
  Twitter APIについてお聞きしたい事があります。
4
4
 
@@ -31,3 +31,77 @@
31
31
 
32
32
 
33
33
  をmypage.phpの特定の場所へ表示したいのですが、どうやったらできますでしょうか?
34
+
35
+
36
+
37
+ mypage.phpの中身です。
38
+
39
+ コード
40
+
41
+ ```
42
+
43
+ <?php
44
+
45
+ session_start();
46
+
47
+
48
+
49
+ require_once 'common.php';
50
+
51
+ require_once 'twitteroauth/autoload.php';
52
+
53
+
54
+
55
+ use Abraham\TwitterOAuth\TwitterOAuth;
56
+
57
+
58
+
59
+ //セッションに入れておいたさっきの配列
60
+
61
+ $access_token = $_SESSION['access_token'];
62
+
63
+
64
+
65
+ //OAuthトークンとシークレットも使って TwitterOAuth をインスタンス化
66
+
67
+ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
68
+
69
+
70
+
71
+ //ユーザー情報をGET
72
+
73
+ $user = $connection->get("account/verify_credentials"); //(ここらへんは、Twitter の API ドキュメントをうまく使ってください)
74
+
75
+
76
+
77
+ //GETしたユーザー情報をvar_dump
78
+
79
+ var_dump( $user );
80
+
81
+ ?>
82
+
83
+
84
+
85
+ <!DOCTYPE html>
86
+
87
+ <html lang="ja">
88
+
89
+ <head>
90
+
91
+ <meta charset="utf-8"/>
92
+
93
+ <title>テスト</title>
94
+
95
+ </head>
96
+
97
+ <body class="m-page--fluid m--skin- m-content--skin-light2">
98
+
99
+ <div class="m-grid m-grid--hor m-grid--root m-page">
100
+
101
+ <?php include dirname(__FILE__) . '/php/header.php';?>
102
+
103
+ ...
104
+
105
+
106
+
107
+ ```