Trying to fetch something via HttpObject
by Theref · in Torque 3D Beginner · 05/12/2013 (12:13 am) · 10 replies
So basically I want to fetch the string on this page
http://taisen.co/test.php
Then pass the string via echo.

However, what I got is the header info of that page. I just want to get that "success" or whatever strings are on that content. Anyone can give me pointer?
http://taisen.co/test.php
Then pass the string via echo.
function coba()
{
$myHttpObject = new HttpObject(CharLogin);
$myHttpObject.get("www.taisen.co:80", "/test.php", "");
}
function CharLogin::onLine( %this, %line )
{
%client = %this.clientid;
echo(%line);
}
function CharLogin::onConnectionDenied( %this )
{
echo ("Denied:");
}
function CharLogin::onDNSFailed( %this )
{
echo ("dns failed:");
}
function CharLogin::onConnectFailed( %this )
{
echo ("connectino faileds:");
}
However, what I got is the header info of that page. I just want to get that "success" or whatever strings are on that content. Anyone can give me pointer?
#2
05/12/2013 (2:18 am)
updated the reply above to be a bit more detailed.
#3
hm, I'm not trying to make a login or something similar that requires SQL interaction.
I just want my Torque to read whatever inside the test.php (Like newsfeed, ) put it inside a string variable then print it at console
05/12/2013 (2:25 am)
function coba()
{
$myHttpObject = new HttpObject(CharLogin);
$myHttpObject.get("www.taisen.co:80", "/test.php", "");
}
function CharLogin::onLine( %this, %line )
{
if(StrStr(%line, "Connected") != -1)
{
echo ("Success!!!");
}
%client = %this.clientid;
echo(%line);
}
function CharLogin::onConnectionDenied( %this )
{
echo ("Denied:");
}
function CharLogin::onDNSFailed( %this )
{
echo ("dns failed:");
}
function CharLogin::onConnectFailed( %this )
{
echo ("connectino faileds:");
}Still showing same result as this http://hfimage.net/images/wjygxlfoud6l3afxq8o.pnghm, I'm not trying to make a login or something similar that requires SQL interaction.
I just want my Torque to read whatever inside the test.php (Like newsfeed, ) put it inside a string variable then print it at console
#4
Try:
echo ("Connected");
and then in the Torque 3D console see if you get a Success!!! ?
05/12/2013 (2:39 am)
Are you doing an echo on the php file ? Try:
echo ("Connected");
and then in the Torque 3D console see if you get a Success!!! ?
#6
echo "Connected";
On my php files at http://taisen.co/test.php
But still same output, *confuses*
05/12/2013 (3:16 am)
Ok, changed it to echo "Connected";
On my php files at http://taisen.co/test.php
But still same output, *confuses*
#7
05/12/2013 (4:41 am)
ok, let me do a test.. will get back to you
#8
I take it on your PHP file you are using
....
I'm using version 1.2 of Torque, not Torque MIT.. which version are you using and I'll test that... there was an issue with HTTPObject in v1.1, so hopefully that has not gone across to v2.0 or v3.0 of MIT.
05/12/2013 (4:50 am)
works at this end.. I take it on your PHP file you are using
<?php echo "Connected"; ?>
....
I'm using version 1.2 of Torque, not Torque MIT.. which version are you using and I'll test that... there was an issue with HTTPObject in v1.1, so hopefully that has not gone across to v2.0 or v3.0 of MIT.
#9
Eh, hmm, it seems my version is v2.0 or whatever is in here 2 days ago.
http://www.garagegames.com/products/torque-3d
Would be good if there's someone out there with same version like me to test it out
05/12/2013 (4:53 am)
Yeah exactly like that!Eh, hmm, it seems my version is v2.0 or whatever is in here 2 days ago.
http://www.garagegames.com/products/torque-3d
Would be good if there's someone out there with same version like me to test it out
#10
05/12/2013 (4:58 am)
I have the v2.0 MIT version, v3.0 is available. I'll give it a test with those versions later today, unless someone gets back to you before then.
Torque Owner Jules
Something2Play
function CharLogin::onLine( %this, %line )
if(StrStr(%line, "Connected") != -1) { echo ("Success!!!"); }Then in your test.php after your SQL query, something like: (more advanced SQL would have better coding for SQL injection attacks).
add:
if ($num_rows == 0) { // if Bob is not found, fail echo "Failed"; exit(); } // check to see if the result was Bob from the database echo "Connected";What this does is basic.. but checks to see if any results were brought back and then show whether or not it failed. From here you can define what you pass from TorqueScript to pass a query into the php call which then would check the database via the SQL query for a result.