Jump to content
Sign in to follow this  
Izebize

PHP variables with COM Object

Recommended Posts

Izebize

How can I pass PHP variables with COM Object?

In the Help file there is a simple http com object example. Something like this:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://localhost/userlist.php?userid=3")
$oHTTP.Send()

Here's the userlist.php source:

<?php
$page = $_GET['userid'];
$log = fopen("users.txt", "a");
fwrite($log, $page ."\n");
fclose($log);
?>

If I open in a browser the url, it will save "3" into users.txt, but if I use the COM Object method, it won't write "3" into users.txt.

I tried $oHTTP.Open with "PUT", and "POST" too, without success.

What's wrong?

Share this post


Link to post
Share on other sites
Richard Robertson

Is it possible that the object is using a cached page?

Share this post


Link to post
Share on other sites
Izebize

I don't think so.

No, I tried with a different php filename, but it doesn't work.

Edited by Izebize

Share this post


Link to post
Share on other sites
Richard Robertson

So is the PHP file adding a blank line when you call it from the AutoIt script?

Share this post


Link to post
Share on other sites
Izebize

Yes, I want to send data without showing a window, with php.

No, the php, doesn't add blank line.

Share this post


Link to post
Share on other sites
Yuraj

I had same problem but I didn't find any solution with winhttprequest. But maybe it will work when you will add to http header:

Content-Type: application/x-www-form-urlencoded

You can also try this :

#include <INet.au3>
$users= _INetGetSource("http://localhost/userlist.php?userid=3")
Edited by Yuraj

ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID)

Share this post


Link to post
Share on other sites
Izebize

_INetGetSource doesn't work.

How can I add header?

Share this post


Link to post
Share on other sites
Richard Robertson

If the PHP isn't adding a blank line (since it is reading a blank user is what you thought), that means that your script isn't even reaching the PHP host.

Do you have AutoIt allowed by your firewall?

Share this post


Link to post
Share on other sites
Izebize

It's within local area, and I don't have firewall for it. I use firewall only for WAN. I'm sure it can reach the php.

I will check the sended packets with Wireshark and after I compared I'll post the differences.

Share this post


Link to post
Share on other sites
Richard Robertson

Firewalls block local traffic too. Make sure it's cleared.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.