InternetGet and User-Agent?

Questions and information about creating Internet aware NeoBook applications. Including PHP, HTML, FTP, HTTP, Email, etc.

Moderator: Neosoft Support

Locked
Ndzn
Posts: 134
Joined: Sun Sep 20, 2009 8:37 am
Contact:

InternetGet and User-Agent?

Post by Ndzn »

Is there any way to pass the User Agent in the InternetGet command?

To clarify, some pages (e.g., "...script?param=value") will return full results when using a browser. Whereas, using NeoBook's InternetGet in certain cases will not return the same results as an actual browser.

For example, using cURL you can do something like this...

Code: Select all

curl -A "Mozilla/5.0 (compatible; MSIE 7.01; Windows NT 5.0)" http://www.somewebsite.com
Is there some equivalent for NeoBook's GET?

Can you add the User-Agent into the InternetGet command so that InternetGet impersonates (presents itself as) a web browser?
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Post by Neosoft Support »

Currently, the agent is set to the pub title, so you could try something like this:

SetVar "[PubTitle]" "Mozilla/5.0 (compatible; MSIE 7.01; Windows NT 5.0)"
InternetGet...
SetVar "[PubTitle]" "Original Title"
NeoSoft Support
Ndzn
Posts: 134
Joined: Sun Sep 20, 2009 8:37 am
Contact:

Post by Ndzn »

Thanks, I'll try that.

What you're describing is similar to what I used to make my server logs files report which version of my app is visiting my site for data. However, the difference is that I found that the Book Title seemed to be what was carrying the User-Agent, not the PubTitle, nor AppTitle.

In "Book Properties > General > Title" I entered the full version and whatever app info I needed to see in my server log files...

"My Application (2.4.1.3 -- etc.)"

Then, in my Startup Actions set the PubTitle and AppTitle to what I would rather users to see on their desktop...

SetVar "[PubTitle]" "My Application"
SetVar "[AppTitle]" "My Application"

Changing the PubTitle and/or App Title made no difference for me in the server logs.

?) Do you think both of these might be the same situation?
?) Would a future version of NeoBook be able to include some advanced options for the Internet Actions?

Thanx...
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Post by Gaev »

Would a future version of NeoBook be able to include some advanced options for the Internet Actions?
In keeping with the pattern for other Mail/HTTP functions ...

[HTTPUserID]
[HTTPUserPassword]
[HTTPPort]

etc. etc.

... perhaps the best option would be to designate another Predefined Global Variable ... e.g. [HTTPUserAgent] ... and if it was not blank/empty, its content would be used instead of the [PubTitle].
Ndzn
Posts: 134
Joined: Sun Sep 20, 2009 8:37 am
Contact:

Post by Ndzn »

Gaev wrote:... perhaps the best option would be to designate another Predefined Global Variable ... e.g. [HTTPUserAgent]
I agree. That makes perfect sense.


More Internet Actions and advanced options might still be helpful though. For example another problem I'm running into is that there is no action that can determine a file type if it's not already in the URL. If a download link is actually a script...

../script?param=value

...and you don't already know the file type, then there's no way to detect what extension to Save As.
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

Post by Tony Kroos »

Also you may think about adding variables for some other http-headers, for example [HTTPReferer] or [HTTPHost]. without correct referer header, it's just impossible to perform internet actions for some webpages that verify the source of the request.
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Post by Neosoft Support »

... perhaps the best option would be to designate another Predefined Global Variable ... e.g. [HTTPUserAgent] ... and if it was not blank/empty, its content would be used instead of the [PubTitle].
Also you may think about adding variables for some other http-headers, for example [HTTPReferer] or [HTTPHost].
Good suggestions. We'll look into it.
NeoSoft Support
schmutly
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: InternetGet and User-Agent?

Post by schmutly »

Gaev,
How would i be able to use http global variables for use with the Tinypng API?
Theres really no tutorials and i think if someone could show just how to (if possible) access the API in neobook.
Can this be done or help in the right direction would be grateful?
Rob
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: InternetGet and User-Agent?

Post by Gaev »

Rob:
How would i be able to use http global variables for use with the Tinypng API?
You can not use NeoBook's InternetPost to make requests to tinypng via their API service.

1) It says ...
Response when successful

If the HTTP status code is 201, the image was successfully compressed. Use the Location header to retrieve the compressed file.
... NeoBook's InternetPost command does not have facilities to access any information returned in the Header of the response from an http/https request.

2) It says ...
The Authorization header should contain a Base64 digest of the string api:KEY, where KEY is the API key that has been provided to you
... I do not think you can specify the Authorization header via NeoBook's InternetPost command.


It might be possible to access this service from a NeoBook Publication by using an HTML document in a WebBrowser ... that calls the service using some jQuery commands.
schmutly
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: InternetGet and User-Agent?

Post by schmutly »

What about using something like this: Curl for windows ?
Surely that would work? I will try this as its open source and the NB app will be run from windows only.
Will try to work this out. As there's no support for accessing APIs easily would be a great plugin
and a JSON plugin would be great too.
I'll try to sus this out. I have Winautomation and i could probably use "Invoke Web Service" as
it is an http client that you can configure the request it sends so that it can be used for both raw web services and web pages.
Rob
schmutly
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: InternetGet and User-Agent?

Post by schmutly »

EXCELLENT :D :D That worked.EASY.
I will put down the steps here, if anyone interested, later.
This is GREAT if anything in future needs Curl with https as well but
im still a blur on APIs using json but ill learn that further down the road.
Now to get this working in Neobook (it works a treat in DOS prompt so shouldn't be a problem) :)
Thanks Gaev, as usual, for your help.
Rob
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: InternetGet and User-Agent?

Post by Gaev »

Rob:

When you first posted this Topic on the Forum, I thought you were looking for a method to use the tinypng facility purely from a NeoBook created Application.

In your last post you mentioned downloading/installing another program i.e. "curl for windows" ... in which case you might look into something like ...

http://onlinecurl.com/

... avoid having to install anything on your machine.


Also, you might consider using just a plain HTML document to access tinypng ... if you do ...

a) the following website pages might help you to understand how to set content on headers of requests and read content of headers in responses (both of which are required in order to deploy the services offered by tinypng) ...

https://developer.mozilla.org/en/docs/S ... st_headers
http://www.w3schools.com/ajax/ajax_xmlh ... t_send.asp
http://www.w3schools.com/dom/dom_http.asp

b) take a look at (browser based) facilities like ...

http://www.hurl.it/
http://requestmaker.com/
http://jsbin.com/
http://jsfiddle.net/

... that provide a playground for you to experiment with making "requests that deploy headers" via Javascript.
schmutly
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: InternetGet and User-Agent?

Post by schmutly »

Hi Gaev, no...you were correct..I AM trying to make a neobook APP for myself and
a friend. I have npdrop and want to drop the files onto neobook app and then can download
them directly to a folder on PC.
So..the simplest way was to use the curl.exe program for windows, have it embedded into neobook
and extracted when first run. It doesn't need to go into system folder and the SSL privacy key files
just both reside in the temp or main program folder.
One of the methods to be used can be Curl it said so thats why i went that way and tried the curl
for windows however all your urls, research and suggestions are really the way to go.
Be good if someone does a tutorial on using APis but thats wishful thinking :/
OK...thanks for your time..i will look into what you wrote as part of some real learning..
Thanks for the research and help
Rob
Locked