Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
72c4c507
Unverified
Commit
72c4c507
authored
Feb 22, 2018
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/faucet: resolve twitter user from final redirect
parent
1e457b65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
faucet.go
cmd/faucet/faucet.go
+7
-2
No files found.
cmd/faucet/faucet.go
View file @
72c4c507
...
@@ -686,8 +686,6 @@ func authTwitter(url string) (string, string, common.Address, error) {
...
@@ -686,8 +686,6 @@ func authTwitter(url string) (string, string, common.Address, error) {
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
}
}
username
:=
parts
[
len
(
parts
)
-
3
]
// Twitter's API isn't really friendly with direct links. Still, we don't
// Twitter's API isn't really friendly with direct links. Still, we don't
// want to do ask read permissions from users, so just load the public posts and
// want to do ask read permissions from users, so just load the public posts and
// scrape it for the Ethereum address and profile URL.
// scrape it for the Ethereum address and profile URL.
...
@@ -697,6 +695,13 @@ func authTwitter(url string) (string, string, common.Address, error) {
...
@@ -697,6 +695,13 @@ func authTwitter(url string) (string, string, common.Address, error) {
}
}
defer
res
.
Body
.
Close
()
defer
res
.
Body
.
Close
()
// Resolve the username from the final redirect, no intermediate junk
parts
=
strings
.
Split
(
res
.
Request
.
URL
.
String
(),
"/"
)
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
}
username
:=
parts
[
len
(
parts
)
-
3
]
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
""
,
common
.
Address
{},
err
return
""
,
""
,
common
.
Address
{},
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment