PHP Access to status.xml

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
slant53
New Cone
New Cone
Posts: 2
Joined: 20 Oct 2013 02:15

PHP Access to status.xml

Postby slant53 » 20 Oct 2013 02:26

I have VLC 2.1.0 and am making my first attempt to access the web interface with PHP. With a browser, I can access localhost:8080 (although it requires me to set a password in VLC in order to access the web interface) and localhost:8080/requests/status.xml. My code uses $file = file_get_contents('http://localhost:8080/requests/status.xml'); but when I try to run I get a 'Not Authorized' message. If I remove the password from VLC, I get in but I only get the code for the 'You must set a password' page. I've found various ways to pass credentials (user id and passwords) to file_get_contents but VLC only needs a password, not an ID.

Can someone offer advice on how to get in?

Thanks

JSLover
Cone that earned his stripes
Cone that earned his stripes
Posts: 116
Joined: 20 Mar 2012 00:08
VLC version: 2.1.5
Operating System: Win7
Location: r.secsrv.net/youtube.lua

Re: PHP Access to status.xml

Postby JSLover » 20 Oct 2013 05:38

I've found various ways to pass credentials (user id and passwords) to file_get_contents but VLC only needs a password, not an ID.
...that shouldn't matter. I have not looked into this at all, but: I would try sending an empty string as the username, or just send any string for the username...if VLC only wants a password, perhaps it will ignore any username you send it?

When you login with a browser, the prompt probably has a username field, which you ignore & type into the password field: so it's the same: skip the username in PHP too -- if you literally can't skip it (depending on the method you are using to give credentials to file_get_contents() -- & I mean really can't...as in: "I tried it & it really didn't work", not just "I don't think that'll work"), then provide any string, like "test", for the username & see if VLC complains.
"why the f*** do i need a google+ account to comment on a video?" — jawed (2013) (about YouTube's new requirement of Google+)

youtube.lua — Play YouTube videos in VLC!
Updated: Thu, Jan 15, 2015 --- 1/15/15, 7:19:19pm EST

forum.videolan.org/viewtopic.php?f=29&t=111977&p=379147#p379147
Sigh, the above can't be a link: "You cannot use certain BBCodes: [url]."...so, I can't even link back to a post on this forum?
How about this: can long-term/trusted users be allowed links in sigs?

slant53
New Cone
New Cone
Posts: 2
Joined: 20 Oct 2013 02:15

Re: PHP Access to status.xml

Postby slant53 » 20 Oct 2013 14:03

Thanks.

What finally worked (in case anyone else runs into this) was:

Code: Select all

$context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode(":password") ) )); $file = file_get_contents('http://localhost:8080/requests/status.xml',false,$context);
Normally there is an id in the encoded string (i.e. userid:password) but I just removed it and it worked.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 25 guests