Hello Leonardo. I have to ask the simple question: Does the URL you
are specifying work with a browser? I mean 404 error sounds like a
server response.
Also - Note I have run into issues sometimes working with Microsoft
Servers and or .Net code that interacts with my home grown web servers
etc. Microsoft has some peculiar issues... most of which is just strict
http and network rules that are not necessarily "standard"...
Your reasons for calling and getting some data from a php script do not
need to be defended - we all do whatever is best or needed for our apps
to do their thing.
I think your issue here might be something as simple as making sure your
link works with a browser first - then works with Synapse.
I'm not a fan boy nor do I understand half of the Synapse library... but
the half I do work with - when I can get a sample program working - I
usually can make quite a bit of progress once I manage to get the demo
application to run for me. It's usually a bit of work for me because I
use FreePascal and not Delphi or Lazarus too much and the demo's appear
to be for those environments specifically.
I use a program with these tidbits to read a web page... might do the
trick as a sample for ya:
Note example usage:
jegas_web_requester www.google.com
Code BEGIN
--------------
//=============================================================================
// Note: History at end of File
//=============================================================================
// Search for !...@! to get the various sections of interface
// Search for !#! to get the same secion of implmentation
// ^---- Trying to get this to be correct, not yet though
//=============================================================================
//=============================================================================
// Global Directives
//=============================================================================
{$SMARTLINK ON}
{$PACKRECORDS 4}
{$MODE objfpc}
//=============================================================================
//=============================================================================
program jegas_http_requester;
//=============================================================================
{ INCLUDE i01_jegas_splash.pp}
{$IFDEF win32}
{$INFO | TARGET: Win32}
{$ELSE}
{$IFDEF linux}
{$INFO | TARGET: linux}
{$ELSE}
{$INFO | !!!!! UNKNOWN TARGET PLATFORM !!!!!}
{$ENDIF}
{$ENDIF}
{$INFO =================================================================}
{$INFO | Filename: jegas_http_requester}
{$INFO | Author : Jason P Sage}
{$INFO | Created : 2009-11-14}
{$INFO | Purpose : allow command line httpd requests to be made }
{$INFO =================================================================}
{$IFDEF MIND_CHANGED_ABOUT_SENDING_SCRIPT}
{$INFO CONFIGURED SO SCRIPTS AND REQUEST WILL BE TRANSMITTED TO JAS}
{$INFO SERVER OVER THE WIRE!}
{$ELSE}
{$INFO CONFIGURED SO ONLY REQUEST WILL BE TRANSMITTED TO JAS SERVER}
{$ENDIF}
{$INFO =================================================================}
{ INCLUDE i01_jegas_macros.pp}
Uses
classes
,dos
,httpsend
,sysutils
;
//=============================================================================
const
//=============================================================================
csCRLF = #13#10;
csINET_HDR_CONTENT_LENGTH ='Content-Length: ';
csINET_HDR_CONTENT_TYPE ='Content-Type: ';
csMIME_TextPlain ='text/plain';
csMIME_TextHtml ='text/html';
// csCGI_GET = 'GET';
csCGI_CONTENT_TYPE = 'CONTENT_TYPE';
csCGI_CONTENT_LENGTH = 'CONTENT_LENGTH';
csCGI_DOCUMENT_ROOT = 'DOCUMENT_ROOT';
// csCGI_HTTP_ACCEPT = 'HTTP_ACCEPT';
// csCGI_HTTP_ACCEPT_LANGUAGE = 'HTTP_ACCEPT_LANGUAGE';
// csCGI_HTTP_ACCEPT_ENCODING = 'HTTP_ACCEPT_ENCODING';
// csCGI_HTTP_ACCEPT_CHARSET = 'HTTP_ACCEPT_CHARSET';
// csCGI_HTTP_KEEPALIVE =
'HTTP_KEEPALIVE';//underscore not between keep and alive purposely.
// csCGI_HTTP_CONNECTION = 'HTTP_CONNECTION';
// csCGI_HTTP_COOKIE = 'HTTP_COOKIE';
// csCGI_HTTP_HOST = 'HTTP_HOST';
// csCGI_HTTP_REFERER = 'HTTP_REFERER';
// csCGI_HTTP_USER_AGENT = 'HTTP_USER_AGENT';
// csCGI_HTTP_JEGAS = 'HTTP_JEGAS';
csCGI_PATH_INFO = 'PATH_INFO';
// csCGI_POST = 'POST';
csCGI_QUERY_STRING = 'QUERY_STRING';
// csCGI_REMOTE_ADDR = 'REMOTE_ADDR';
// csCGI_REMOTE_PORT = 'REMOTE_PORT';
csCGI_REQUEST_METHOD = 'REQUEST_METHOD';
// csCGI_REQUEST_URI = 'REQUEST_URI';
// csCGI_SCRIPT_FILENAME = 'SCRIPT_FILENAME';
csCGI_SCRIPT_NAME = 'SCRIPT_NAME';
// csCGI_SERVER_SOFTWARE = 'SERVER_SOFTWARE';
// csCGI_REDIRECT_STATUS = 'REDIRECT_STATUS';
//=============================================================================
//=============================================================================
Var // GLOBALS
//=============================================================================
HTTP: THTTPSend;
saHOST: ansistring;
saOut: ansistring;
//=============================================================================
//=============================================================================
// MAIN
//=============================================================================
Var
bSuccess: boolean;
i8Err: Int64;
saErrorStr: AnsiString;
{$IFDEF MIND_CHANGED_ABOUT_SENDING_SCRIPT}
saDataIn: AnsiString;
{$ENDIF}
saDataOut: ansistring;
//u2IOREsult:word;
// i: integer;//debug thing
Begin
If paramcount=1 Then Begin
saHost:=paramstr(1);
writeln('Host:',saHost);
End;
saOut:='';// our parsed CGI env vars
saDataOut:=''; // final result
HTTP:=THTTPSend.create;
bSuccess:=true;
if bSuccess then
begin
//HTTP.Headers.Add('Jegas: JAS-HTTP Requester 1.0.0');
//HTTP.Headers.Add('Script: '+saScriptFullyQualifiedFilename+'
Result:'+saStr(u2IOResult));//debug thing
//HTTP.Headers.Add('DocRoot: '+saDocRoot);//debug thing
//For i:=0 To paramcount Do HTTP.Headers.Add('Param
'+saStr(i)+':'+paramstr(i));//debug thing
try
bSuccess:=HTTP.HTTPMethod('GET',saHost);
if bSuccess then
begin
write(Http.headers.text);
write(csINET_HDR_CONTENT_TYPE+csMIME_TextHtml +csCRLF);
write('Content-length: ' + inttostr(Http.Document.Size) +
csCRLF+csCRLF);
setlength(saDataOut,Http.Document.Size);
Http.Document.ReadBuffer(PCHAR(saDataOut)^, Http.Document.Size);
end
else
begin
i8Err:=-200907260440;
saErrorStr:='Communication error with host:'+ saHOST+' Result
code: '+inttostr(Http.Resultcode);
end;
finally
end;//try
End;
If not bSuccess then
Begin
saErrorStr:=inttostr(i8Err)+': '+saErrorStr;
saDataOut:=
//'HTTP/1.1 ' + '200 OK' + csCRLF +
//'MIME-version: 1.0'+csCRLF +
//'Allow: GET, POST'+csCRLF +
csINET_HDR_CONTENT_TYPE+csMIME_TextPlain +csCRLF+
'Content-length: ' + inttostr(length(saErrorStr)+4) + csCRLF+csCRLF +
saErrorStr+#13#10#13#10;
End;
write(saDataOut);
HTTP.Free;
End.
//=============================================================================
--------------
Code End
On 6/29/2010 8:53 PM, Leonardo M. Ramé wrote:
> Hi, I'm trying to insert the result of an PHP script into the resulting HTML
> of an fcl-web CGI application by calling it using HttpGetText. This works
> when I call an external page, like "http://www.google.com" but not with an
> internal one, like "http://localhost/mypage.php" (I get an 404 error).
>
> I need to do this because the PHP script has information about logged-in
> users to a website (residing in the same host as my cgi app), and I need to
> access the logged user name and other data this PHP script can access to.
> This PHP script has an abstraction layer to allow the programmer get this
> info, which starts in cookies, then does a couple of sql queries to get the
> results, that's why I use it instead of making all the work with my CGI
> program.
>
> Any hint?
>
> Leonardo M. Ramé
> http://leonardorame.blogspot.com
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> synalist-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/synalist-public
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public