Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mediawikiR
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathieu Loiseau
mediawikiR
Commits
561736e6
Commit
561736e6
authored
7 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
login qui marche (en mode non secure) ?
parent
6153a1ff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DESCRIPTION
+1
-0
1 addition, 0 deletions
DESCRIPTION
R/class.R
+34
-8
34 additions, 8 deletions
R/class.R
with
35 additions
and
8 deletions
DESCRIPTION
+
1
−
0
View file @
561736e6
...
@@ -9,3 +9,4 @@ License: MIT
...
@@ -9,3 +9,4 @@ License: MIT
Encoding: UTF-8
Encoding: UTF-8
LazyData: true
LazyData: true
RoxygenNote: 6.0.1
RoxygenNote: 6.0.1
Imports: RCurl
This diff is collapsed.
Click to expand it.
R/class.R
+
34
−
8
View file @
561736e6
...
@@ -5,12 +5,38 @@
...
@@ -5,12 +5,38 @@
setClass
(
"Mediawikir"
,
representation
(
url
=
"character"
,
user_name
=
"character"
,
auth_token
=
"character"
))
setClass
(
"Mediawikir"
,
representation
(
url
=
"character"
,
user_name
=
"character"
,
auth_token
=
"character"
))
setGeneric
(
"connect"
,
function
(
.Object
,
pass
){})
setGeneric
(
"connect"
,
function
(
.Object
,
pass
){})
#'Connects to mediawiki instance and gets token (to be called by constructor)
#'Connects to mediawiki instance and gets token (to be called by constructor)
#'
setMethod
(
"connect"
,
"Mediawikir"
,
function
(
.Object
,
pass
){
setMethod
(
"connect"
,
"Mediawikir"
,
function
(
.Object
,
pass
){
#get login token
library
(
"RCurl"
)
query
<-
httr
::
POST
(
.Object
@
url
,
paste
(
"connecting : "
,
.Object
@
user_name
,
"/"
,
pass
)
body
=
list
(
action
=
"query"
,
})
meta
=
"tokens"
,
type
=
"login"
,
lgname
=
.Object
@
user_name
,
format
=
"json"
))
httr
::
stop_for_status
(
query
)
response
<-
httr
::
content
(
query
,
"parsed"
,
"application/json"
)
print
(
"query 1"
)
#debug
token
<-
response
$
query
$
tokens
$
logintoken
print
(
token
)
#debug
query
<-
httr
::
POST
(
.Object
@
url
,
body
=
list
(
action
=
"clientlogin"
,
username
=
.Object
@
user_name
,
password
=
pass
,
logintoken
=
token
,
loginreturnurl
=
"http://wiki.lezinter.net"
,
format
=
"json"
))
httr
::
stop_for_status
(
query
)
response
<-
httr
::
content
(
query
,
"parsed"
,
"application/json"
)
print
(
"query 2"
)
#debug
print
(
response
)
#debug
if
(
response
$
clientlogin
$
status
==
"PASS"
){
return
(
token
)
}
else
{
return
(
"0"
)
}
})
#'Creates a new Mediawikir object instance
#'Creates a new Mediawikir object instance
#'
#'
...
@@ -20,8 +46,8 @@ setMethod("connect", "Mediawikir", function(.Object, pass){
...
@@ -20,8 +46,8 @@ setMethod("connect", "Mediawikir", function(.Object, pass){
#'@examples
#'@examples
#' new("Mediawikir", "http://wiki.example.com", "admin", "theadmin'spassword")
#' new("Mediawikir", "http://wiki.example.com", "admin", "theadmin'spassword")
setMethod
(
"initialize"
,
"Mediawikir"
,
function
(
.Object
,
instance_url
,
user
,
pass
){
setMethod
(
"initialize"
,
"Mediawikir"
,
function
(
.Object
,
instance_url
,
user
,
pass
){
.Object
@
url
<-
instance_url
.Object
@
url
<-
paste
(
instance_url
,
"/"
,
"api.php"
,
sep
=
""
)
.Object
@
user_name
<-
user
.Object
@
user_name
<-
user
.Object
@
auth_token
<-
connect
(
.Object
,
pass
)
.Object
@
auth_token
=
connect
(
.Object
,
pass
)
return
(
.Object
)
return
(
.Object
)
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment