Jump to content

Gettting info from php


Recommended Posts

So can someone give me an example of how I would do this. All it is is text from my sql database but the easiest way is through php than trying to make it work with the DB

this code (when modified to your info) will download the page, and save the contents of the page to a file. then all you have to do is parse out the information that you want... hopefully you have a good way to seperate what you want from what you don't, like constant labels "Song -", "Request -" etc...

InetGet("http://yourpage.com/whatever.php","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))
Link to comment
Share on other sites

I do a lot of this same thing, with a bit more complex querys. Remember, you don't have to have an html formated page when doing this. Your Php output can be a simple CSV file.

ex

title,request

dead puppies,play

piano man,play

You can also have sorts, and and a bunch of others in the same php file with $_GET[]

Example:

if(len($_GET[sort])>1){$sort=" ORDER BY " . $_GET[sort];}

$query="Select * from `playlist` " . $where . $sort;

In that example, you would dynamically have a sort if you sent the request like:

InetGet("http://yourpage.com/whatever.php?sort=title","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))

You can do the same for where requests. I would be careful of doing a full query request, as if someone found your text, they could do some real damage like "Drop table playlist"

For safety you can also remove certain characters that could make more than one query, but that is more pphp programming...

Just echo only the result and you should have a nice clean php csv formatted file to work with.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

okay I just got it to download the info from the page and i have the txt now what i'm so confused by autoit. Here i will post the code I got for the player and see if you can have it display the current song that is playing and who requested it.

Here is the code i have so far

#include <GuiConstants.au3>
InetGet("http://www.subsonicradio.com/station/plain.php","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))
#region Object
$oMyError = ObjEvent("AutoIt.Error","Quit")
$oMediaplayer = ObjCreate("WMPlayer.OCX.7") 

If Not IsObj($oMediaplayer) Then Exit

$oMediaplayer.Enabled = true
$oMediaplayer.WindowlessVideo= true
$oMediaPlayer.UImode="invisible"
$oMediaPlayer.URL="http://198.172.227.156:8000/"
$oMediaPlayControl=$oMediaPlayer.Controls
$oMediaPlaySettings=$oMediaPlayer.Settings


#endregion

#region GUI
GuiCreate("Subsonic 128k", 215, 100,(@DesktopWidth-215)/2, (@DesktopHeight-100)/2, -1)

GuiCtrlCreateLabel("Subsonic Radio Streaming Music Player", 10, 10, 200, 20)
$Volume = GuiCtrlCreateSlider(20, 30, 180, 20)
GuiCtrlCreateLabel("Volume", 85, 50, 40, 20)
GUICtrlSetData($Volume, 100)
$Play = GuiCtrlCreateButton("Play", 30, 60, 50, 30)
$Stop = GuiCtrlCreateButton("Stop", 120, 60, 50, 30)

GuiSetState()
$VolLevel = 100
HotKeySet("{F8}", "Hide")
HotKeySet("{F9}", "Show")
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Play
        $oMediaPlayControl.Play
    Case $msg = $Stop
        $oMediaPlayControl.Stop
    Case Else
        If GUICtrlread($Volume) <> $VolLevel Then
            $oMediaPlaySettings.Volume = GUICtrlRead($Volume)
            $VolLevel = GUICtrlRead($Volume)
        EndIf
    EndSelect
WEnd
Exit
#endregion

#region functions
Func Quit()
    $oMediaPlayControl.Stop
    Exit
EndFunc

Func Hide()
    GUISetState(@SW_HIDE)
EndFunc

Func Show()
    GUISetState(@SW_SHOW)
EndFunc
#endregion
Edited by eagle4life69
Link to comment
Share on other sites

Here is a bit of code to show the info if you are only doing that one line thing like your example.

while 1
    tooltip("updating...",0,100)
InetGet("http://www.subsonicradio.com/station/plain.php","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))
$playing=StringReplace($contents,"&","=")
$playing=StringSplit($playing,"=")
tooltip($playing[2] &  @crlf & "requested by " & $playing[4],0,100)
sleep(10000); 10 sec delay
WEnd

This only downloads the page every 10 seconds and displays it as a tooltip on your desktop.

I showed how to seperate the song from the user acording to your php result.

If no user is returned, none are shown. I didn't parse the full MP3 file, as it looks like you might have path and other info in there.

As far as the player, you would have to pull the MP3 song, and give it to the player, etc.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

okay tweeked and it works great but now I can't use my play stop and exit buttons (i just added a exit button)

While 1

   $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Play
        $oMediaPlayControl.Play
    Case $msg = $Stop
        $oMediaPlayControl.Stop
    Case $msg = $Exit
        $oMediaPlayControl.Stop
    Exit
    Case Else
        If GUICtrlread($Volume) <> $VolLevel Then
            $oMediaPlaySettings.Volume = GUICtrlRead($Volume)
            $VolLevel = GUICtrlRead($Volume)
        EndIf
    EndSelect 
InetGet("http://www.subsonicradio.com/station/plain.php","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))
$playing=StringReplace($contents,"&","=")
$playing=StringSplit($playing,"=")
tooltip($playing[2] &  @crlf & "requested by " & $playing[4],0,5)
sleep(10000); 10 sec delay
tooltip("",0,25)

    
sleep(30000); 45 sec delay
WEnd
Exit

this must be the problem

Edited by eagle4life69
Link to comment
Share on other sites

Okay all done

#include <GuiConstants.au3>

InetGet("http://www.subsonicradio.com/station/plain.php","c:\songrequest.txt")
$contents = FileRead("c:\songrequest.txt",filegetsize("C:\songrequest.txt"))
$playing=StringReplace($contents,"&","=")
$playing=StringSplit($playing,"=")

#region Object
$oMyError = ObjEvent("AutoIt.Error","Quit")
$oMediaplayer = ObjCreate("WMPlayer.OCX.7") 

If Not IsObj($oMediaplayer) Then Exit

$oMediaplayer.Enabled = true
$oMediaplayer.WindowlessVideo= true
$oMediaPlayer.UImode="invisible"
$oMediaPlayer.URL="http://198.172.227.156:8000/"
$oMediaPlayControl=$oMediaPlayer.Controls
$oMediaPlaySettings=$oMediaPlayer.Settings


#endregion

#region GUI
GuiCreate("Subsonic 128k", 215, 100,(@DesktopWidth-215)/2, (@DesktopHeight-100)/2, -1)

GuiCtrlCreateLabel("Subsonic Radio 128k", 10, 10, 200, 20)
$Volume = GuiCtrlCreateSlider(20, 30, 180, 20)
GuiCtrlCreateLabel("Volume", 85, 50, 40, 20)
GUICtrlSetData($Volume, 100)

$Play = GuiCtrlCreateButton("Play", 30, 70, 50, 30)
$Stop = GuiCtrlCreateButton("Stop", 90, 70, 50, 30)
$Exit = GuiCtrlCreateButton("Exit", 150, 70, 50, 30)
GuiSetState()
$VolLevel = 100
HotKeySet("{F8}", "Hide")
HotKeySet("{F9}", "Show")
tooltip($playing[2] &  @crlf & "requested by " & $playing[4],0,5)
sleep(10000); 10 sec delay
tooltip("",0,25)


while 1


   $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Play
        $oMediaPlayControl.Play
tooltip($playing[2] &  @crlf & "requested by " & $playing[4],0,5)
sleep(10000); 10 sec delay
tooltip("",0,25)
    Case $msg = $Stop
        $oMediaPlayControl.Stop
    Case $msg = $Exit
        $oMediaPlayControl.Stop
    Exit
    Case Else
        If GUICtrlread($Volume) <> $VolLevel Then
            $oMediaPlaySettings.Volume = GUICtrlRead($Volume)
            $VolLevel = GUICtrlRead($Volume)
        EndIf
EndSelect 
   WEnd
Exit



#endregion

#region functions
Func Quit()
    $oMediaPlayControl.Stop
    Exit
EndFunc

Func Hide()
    GUISetState(@SW_HIDE)
tooltip("",0,25)
EndFunc

Func Show()
    GUISetState(@SW_SHOW)


tooltip($playing[2] &  @crlf & "requested by " & $playing[4],0,5)
;sleep(10000); 10 sec delay


    
;sleep(30000); 45 sec delay
EndFunc


#endregion

I fixed the problem with it not wanting to close, play or stop the song.

I also made it so when you click play or bring it back from the hide position it will show the song

Thanks to everyone for your help this was my first program and now I plan on doing much more

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...