Game Development Community

Accessing Internet

by rennie moffat · in iTorque 2D · 11/28/2010 (3:30 pm) · 14 replies

Hi,
I am just wondering, is there a way through Torque Script only, not using Open Fient or something like that, to have users post score online on Twitter, Facebook etc or are Open Fient and Game Center the way to go?

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
11/28/2010 (3:49 pm)
there is the HTTPObject which you can use to talk to a PHP page of your own.

But if you want to talk to twitter and facebook you will to do have a C++ level implementation, its not possible without doing so. (if you use openfeint or other libraries like the facebook iphone api is up to you)
#2
11/30/2010 (2:08 am)
So this...


in theory, this call would make it?


%this.owner.get ( %address, %requirstURI, [%query] )

%this.post ( %address, %requirstURI, %query, %post )


I did a small test but could not get it to work, mind I was running it just through iTGB. I believe there is an internet access command, that needs to be set but I could not find it. The closet thing was "<iFeatureUseNetwork>0</iFeatureUseNetwork>" in the CommonConfig.xml. But I do not believe that was it. So if you know what that is could you please pass it on.

Also, say if I wanted to get, as in open up www.twitter.com/renniemoffat, that is all. I am confused with %requirstURI, and %query as to what they are. Could you give me an example?

Sorry if this is asking too much. But a little help in this field would go a long way for me.








Is it as simple as that or would I need somehow to link the app itself to the internet?

#3
11/30/2010 (3:36 am)
It is a lot more complicated than that. If you want to interact with Twitter, you're not going to be able to do it with only Torque Script... it looks like you'll have to implement something like MGTwitterEngine and connect that to Torque.

In Torque Script all you can do is grab a simple web page (most likely one that you create and know the format of), and this uses HTTPObject which is what Marc was saying.
#4
11/30/2010 (3:42 am)
So using get(), will allow me to access a web page?



#5
11/30/2010 (3:48 am)
Yes, get will allow you to access a web page. I posted an example here for Johnathan showing how I am using it. I don't know how to fix the problems that he is having though, I never did a pure update to 1.4.
#6
11/30/2010 (4:03 am)
Thanks Justin,


I have some questions tho. Questions are /// in code
function getLoadingTip()  
{  
///liteVersion something with origianl question by Jonathan or a universal need?
    if(isLiteVersion() || isUnverified())  
        return;  
   
///isInternetAvailable, is this a universal? or custom somehow.        
    if(isInternetAvailable()){  
///inItNetwork().... should I just trust these all work?
        initNetwork(); 
///if is loadingTipObject, unsure again what this is.  
        if(!isObject(LoadingTipObject))  
            new HTTPObject(LoadingTipObject);  
 /// so in all fairness I can say 
///loadingTipObject == %this.owner? I like behaviors. 

/// and finally, I noticed this in the Documents, but 
/// what is www.Website.com:80, specifically ":80"
///and "path/to/page.php seems obscure     
        LoadingTipObject.get("www.opsive.com:80", "/path/to/page.php");  
    }  
}  
  
function LoadingTipObject::onLine(%this, %line)  
{  
    if(%line !$= ""){  
        // do what you need to do  
    }  
}




Sorry for asking all these questions but if you can help me gain a better grasp on what is happening here and what needs to be done I would appreciate it.




And thanks for the links.


#7
11/30/2010 (9:06 am)
I am also interested in this. I am (have been for some time) thinking of having the ability to post data from my game app to a specific web site (i.e. mine). I want 100% ownage of scoreboards and the like via my own web site. I want world domination via a pocket app... well maybe not that far, but I prefer to do my own thing and not have to rely on third party things that carry a lot of extra baggage. For me, most third party apps like openfeint carry too much extra shite. I think the average gamer just wants to compete with others in as simple a way as possible, via an online global scoreboard, without any extra baggage. Most gamers are not social at all, they just want to compete against others and win. Gamers are not interested in social networking in my opinion.



#8
11/30/2010 (2:54 pm)
Rennie, I answered with //-->

function getLoadingTip()  
{  
///liteVersion something with origianl question by Jonathan or a universal need?
//-->isLiteVersion checks to see if the app is a lite version and isUnverified checks to make sure the app isn't cracked.  If either of those cases are true, I don't get the loading tip.  You don't need either of these to get Internet to work.
    if(isLiteVersion() || isUnverified())  
        return;  
   
///isInternetAvailable, is this a universal? or custom somehow.  
//-->I have isInternetAvailable() defined in iPhoneReachability, I can't remember if that comes with iTGB1.4 or not      
    if(isInternetAvailable()){  
///inItNetwork().... should I just trust these all work?
//--> I know that I didn't create this function, so yes, just trust that it works.  It'll start the network up if it isn't alread.
        initNetwork(); 
///if is loadingTipObject, unsure again what this is.  
//--> loadingTipObject is the object that will actually get the HTTP page.  You can name it whatever you want.  In my case, I am getting the loading tips so I called loadingTipObject.
        if(!isObject(LoadingTipObject))  
            new HTTPObject(LoadingTipObject);  
 /// so in all fairness I can say 
///loadingTipObject == %this.owner? I like behaviors. 
//--> no, that won't work.  I do not recommend using behaviors for this.

/// and finally, I noticed this in the Documents, but 
/// what is www.Website.com:80, specifically ":80"
///and "path/to/page.php seems obscure     
//--> 80 is the port, all web servers will respond on port 80. /path/to/page.php is the php page that I created that will randomly select the loading tip.  This is completely game dependent and you'll need to create your own page for whatever purposes you want.
        LoadingTipObject.get("www.opsive.com:80", "/path/to/page.php");  
    }  
}  
  
function LoadingTipObject::onLine(%this, %line)  
{  
    if(%line !$= ""){  
        // do what you need to do  
    }  
}


Mark,

I completely agree with you, initially I just added the score board and no social features. Doing a score board correctly is a little bit more complicated than just doing a POST to a php page though - you're going to have to worry about the integrity of the data. With War Evolved I do a hash of the data that I want to send and then encrypt that hash with an encryption scheme. When it gets to my web server I then unencrypt the hash, and compute a separate hash of the data. If the two hashes match, I am 99.99% sure the data is real. I highly doubt anybody will spend any time trying to break the War Evolved encryption.

But I would also consider adding Game Center. It is really easy to add and you get a cool Game Center logo next to your app. I definitely would not do one or the other, but I think having the combination of the two is a good compromise.
#9
11/30/2010 (8:36 pm)
Thank You Justin,

I have answered with "///LL"


view plainprint?
function getLoadingTip()    
{    
///liteVersion something with origianl question by Jonathan or a universal need?  
//-->isLiteVersion checks to see if the app is a lite version and isUnverified checks to make sure the app isn't cracked.  If either of those cases are true, I don't get the loading tip.  You don't need either of these to get Internet to work. 
///LL are Lite and Verified univeraal or custom to this persons app?
    if(isLiteVersion() || isUnverified())    
        return;    
     
///isInternetAvailable, is this a universal? or custom somehow.    
//-->I have isInternetAvailable() defined in iPhoneReachability, I can't remember if that comes with iTGB1.4 or not        
///LL so this is something native that is  must? 
    if(isInternetAvailable()){    
///inItNetwork().... should I just trust these all work?  
//--> I know that I didn't create this function, so yes, just trust that it works.  It'll start the network up if it isn't alread.  
///LL ok. :)
        initNetwork();   
///if is loadingTipObject, unsure again what this is.    
//--> loadingTipObject is the object that will actually get the HTTP page.  You can name it whatever you want.  In my case, I am getting the loading tips so I called loadingTipObject. 
///LLso could this object be %this.owner?  
        if(!isObject(LoadingTipObject))    
            new HTTPObject(LoadingTipObject);    
 /// so in all fairness I can say   
///loadingTipObject == %this.owner? I like behaviors.   
//--> no, that won't work.  I do not recommend using behaviors for this.  
///LL oh. So in script, I know I should ask this elsewhere but since I am here, would simply naming and classing an object via level.t2d then having that file called in the game cs what I am looking at?  
/// and finally, I noticed this in the Documents, but   
/// what is www.Website.com:80, specifically ":80"  
///and "path/to/page.php seems obscure       
//--> 80 is the port, all web servers will respond on port 80. /path/to/page.php is the php page that I created that will randomly select the loading tip.  This is completely game dependent and you'll need to create your own page for whatever purposes you want. 
///LL ok nut what if I am goinig to say "www.renniemoffat.com/portfolio"?  
        LoadingTipObject.get("www.opsive.com:80", "/path/to/page.php");    
    }    
}    
    
function LoadingTipObject::onLine(%this, %line)    
{    
    if(%line !$= ""){    
        // do what you need to do    
    }    
}







Thanks again Justin, this means a ton.


Cheers.
#10
12/01/2010 (6:41 am)
Justin,

Thanks for your feedback. It appears as though the kind of thing I had in mind is pretty much what you are already doing with your game, so that's good news.

Another thing I like about keeping everything central to my own server is that I could easily add other things like forums that could eventually build a network of users. Then, it would be easy to build a list of email addresses of those users and use that information for marketing purposes (blogs, news letters etc ). The more direct control you have over this type of data will greatly enhance your marketing potential in my opinion.

Thanks,
Mark
#11
12/02/2010 (12:08 am)
Rennie -

Quote:
are Lite and Verified univeraal or custom to this persons app?
Custom to my app. Ignore it.

Quote:
so this is something native that is must?
I got in the habit of checking to make sure Internet was available before I did anything networking related. You can probably get by without it if you wanted to.

Quote:
so could this object be %this.owner?
No, %this.owner is null in that function. It has no %this context. I said that you can name it whatever you want meaning it doesn't have to be named "LoadingTipObject", it could be "RennieObject" or "R" for example. Use whatever makes sense.

Quote:
So in script, I know I should ask this elsewhere but since I am here, would simply ....
Don't put this object in level. For one thing, that doesn't make much sense if you did. The other reason is that you are just creating the object within the first function, so there is no reason to.. you don't want it just hanging around with no real purpose.

Quote:
what if I am goinig to say "www.renniemoffat.com/portfolio"?

LoadingTipObject.get("www.renniemoffat.com:80", "/portfolio");
#12
12/02/2010 (12:15 am)
Me:
so could this object be %this.owner?

You:
No, %this.owner is null in that function. It has no %this context. I said that you can name it whatever you want meaning it doesn't have to be named "LoadingTipObject", it could be "RennieObject" or "R" for example. Use whatever makes sense.

Me:
I know this is a basic question so if it is too much touble to explain but I am having difficulty in knowing what this object is. Is it a simple object in the scene named "whateverObject"? .......


However, the above may have been answered here...
Me:
So in script, I know I should ask this elsewhere but since I am here, would simply ....

You:
Don't put this object in level. For one thing, that doesn't make much sense if you did. The other reason is that you are just creating the object within the first function, so there is no reason to.. you don't want it just hanging around with no real purpose.





So ":80" is an essential port that will allow me to access the specified web page?









And thank you again, you have no idea how valuable this is.
Much appreciated.
Rennie
#13
12/02/2010 (3:47 pm)
"So ":80" is an essential port that will allow me to access the specified web page?"

@Rennie - By default, all HTTP traffic utilizes port 80. Unless you have specifically set up another port to be utilized by your app-specific back-end code, keep this set to 80.

If you have access to your web server preferences, you can change the port used by this code (more involved than just changing the port number as you also have to set up the virtual paths for where that port points). This, in essence, provides another layer of security as no one could just navigate through a regular web browser and attempt to sniff out and fake leader board queries. If they don't know your custom port, they cannot access he content. This is an advanced topic but I just wanted to give you as thorough a response as possible (without getting too detailed) so you'd understand that a) the "80" is significant and b) it can be changed if desired (and assuming you have access).

Hope this helps.
#14
09/23/2011 (1:43 am)
it doesn't work in iTorque 1.5 preview 1 :(