Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F308
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Authored By
stwalkerster
Apr 8 2016, 7:43 PM
2016-04-08 19:43:29 (UTC+0)
Size
870 B
Referenced Files
None
Subscribers
None
View Options
<?php
ini_set
(
"user_agent"
,
'ExampleProject/0.0 (wikimedia@stwalkerster.co.uk)'
);
// bomb out early if no username specified
if
(!
isset
(
$_GET
[
'username'
]))
{
echo
"No username specified!"
;
return
;
}
// get the API result as a JSON string
$json
=
file_get_contents
(
"https://en.wikipedia.org/w/api.php?action=query&format=json&list=users&usprop=editcount&ususers="
.
htmlspecialchars
(
$_GET
[
"username"
]));
// decode the JSON in to an associative array (second parameter enforces array rather than object)
$conf
=
json_decode
(
$json
,
true
);
// Use isset() to check if something is set - that way you don't get PHP Notices
if
(!
isset
(
$conf
[
'query'
][
'users'
][
'0'
])
||
isset
(
$conf
[
'query'
][
'users'
][
'0'
][
'missing'
]))
{
echo
"The user '"
.
htmlspecialchars
(
$_GET
[
"username"
])
.
"' does not exist."
;
}
else
{
echo
$conf
[
'query'
][
'users'
][
'0'
][
'editcount'
];
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
277
Default Alt Text
(870 B)
Attached To
Mode
P13 (An Untitled Masterwork)
Attached
Detach File
Event Timeline
Log In to Comment