Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이해님
/
term-project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yulim KIM
2020-12-03 21:12:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bc127e29c646042cd21ce9bea8f8481df2b589b8
bc127e29
1 parent
f848f7e7
add retweet,search function
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
twitter-controller.js
twitter-controller.js
View file @
bc127e2
...
...
@@ -13,6 +13,7 @@ exports.getUserTweets = async function(req, res){
try
{
let
data
=
client
.
get
(
'statuses/user_timeline'
,
req
.
params
,
function
(
error
,
tweets
,
response
){
//트위터 api에서 유저의 타임라인을 가져옴 req.params에 유저 아이디가 들어있음
if
(
!
error
){
console
.
log
(
tweets
);
//가져온 타임라인 내용 콘솔창에 출력
res
.
render
(
'timeline.html'
,
tweets
);
//timeline.html 화면에 뿌려줌 그리고 tweets값을 저 페이지로 보냄
}
...
...
@@ -24,3 +25,38 @@ exports.getUserTweets = async function(req, res){
res
.
sendStatus
(
500
);
}
}
exports
.
getUserSearch
=
async
function
(
req
,
res
){
try
{
let
searchdata
=
client
.
get
(
'search/tweets'
,
req
.
params
,
function
(
error
,
tweets
,
response
)
{
//search
if
(
!
error
){
console
.
log
(
tweets
);
res
.
render
(
'timeline.html'
,
tweets
);
}
});
//입력값 바꿀 필요 있음(?)
}
catch
(
err
){
console
.
log
(
err
);
res
.
sendStatus
(
500
);
}
}
exports
.
getUserRetweet
=
async
function
(
req
,
res
){
try
{
let
retweetdata
=
client
.
get
(
'statuses/user_timeline'
,
req
.
params
,
function
(
error
,
tweets
,
response
)
{
//리트윗
if
(
!
error
){
tweets
.
sort
(
function
(
a
,
b
){
return
b
.
retweet_count
-
a
.
retweet_count
;
});
//리트윗 data 내림차순로 정렬(?)
console
.
log
(
tweets
);
res
.
render
(
'timeline.html'
,
tweets
);
}
});
}
catch
(
err
){
console
.
log
(
err
);
res
.
sendStatus
(
500
);
}
}
...
...
Please
register
or
login
to post a comment