Home AMX User Forum AMXForums Archive Threads AMX Applications and Solutions

Wont connect

<code>

Define_Function Tide_Client_Connection()
{
//Ip_Client_Open(dvDevice1.Port,'tidesandcurrents.noaa.gov',80,1)
IP_CLIENT_OPEN(dvDevice1.port,'www.tides.info',80,1)
Wait 10
{
Tide_Get_The Data_Pacmanstyle()
}
}

Define_Function Tide_Get_The Data_Pacmanstyle()
{
//http://www.tides.info/?command=rss&location=Boston%2c+Massachusetts
Send_String dvDevice1,"'GET /?command=rss&location=Boston%2c+Massachusetts',CRLF"
Send_String dvDevice1,"'Host: www.tides.info',CRLF"
Send_String dvDevice1,"'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',CRLF"
Send_String dvDevice1,"'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',CRLF"
Send_String dvDevice1,"CRLF"
}

DEFINE_START
Create_Buffer dvdevice1,cString
Tide_Client_Connection()
Modified_Date = "ITOA(DATE_TO_YEAR(LDATE)),'-',ITOA(DATE_TO_MONTH(LDATE)),'-',ITOA(DATE_TO_DAY(LDATE))";
</code>

I keep getting an error when I try to connect to the website. Does it have to do with the %2c+ within the Get command???

Comments

  • ericmedleyericmedley Posts: 4,177
    davidv wrote: »
    <code>


    Define_Function Tide_Get_The Data_Pacmanstyle()
    {
    //http://www.tides.info/?command=rss&location=Boston%2c+Massachusetts
    Send_String dvDevice1,"'GET /?command=rss&location=Boston%2c+Massachusetts',CRLF"
    Send_String dvDevice1,"'Host: www.tides.info',CRLF"
    Send_String dvDevice1,"'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',CRLF"
    Send_String dvDevice1,"'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',CRLF"
    Send_String dvDevice1,"CRLF"
    }

    DEFINE_START
    Create_Buffer dvdevice1,cString
    Tide_Client_Connection()
    Modified_Date = "ITOA(DATE_TO_YEAR(LDATE)),'-',ITOA(DATE_TO_MONTH(LDATE)),'-',ITOA(DATE_TO_DAY(LDATE))";
    </code>

    I keep getting an error when I try to connect to the website. Does it have to do with the %2c+ within the Get command???


    I would think you'd not want to break up the string being sent as you do.

    Here's how I do it.
    SEND_STRING HTTP_CLIENT,"'GET /ip.asp HTTP/1.1',13,10,
                          'Accept: */*',13,10,
                          'Accept-Language: en-us',13,10,
                          'Accept-Encoding: gzip, deflate',13,10,
                          'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.1.4322)',13,10,
                          'Host: www.amx.com',13,10,13,10"
    
  • jweatherjweather Posts: 320
    Send_String dvDevice1,"'GET /?command=rss&location=Boston%2c+Massachusetts HTTP/1.0',CRLF"
    

    Try that instead -- you missed the HTTP/1.0 on the end. The %2c is the URL encoding for a comma. (note that $2C = comma)

    Breaking the request into multiple lines won't hurt anything -- the server will wait until it sees the double newline at the end of the request to process it.
  • DHawthorneDHawthorne Posts: 4,584
    Pretty much any web server will choke on a GET command that doesn't include the HTML encoding tag. Without it, it doesn't know what format to output.
  • davidvdavidv Posts: 90
    Working

    Its working now thanks. I must have missed that. I am still new to AMX programming.
Sign In or Register to comment.