I want to send a value from my website to my arduino using httprequest.
as the image explain, i want to enter my site from a device (let's say mobile phone) and send a request to my arduino from my website (webserver)
so i'm having this problems:
1- how to address the arduino without dns, should i have a fixed ip address for my arduino, is there any way else ?
2- what is the PHP code that i need to let the website send the request ??
i know i can connect arduino to web using httpclient, but i want the reverse process, that is connect the website to arduino ( the website as client and a arduino as a server)
is there anyway to do that ?
thank you and sorry for my bad english
I've recently made a similar project with a Raspberry Pi. But this doesn't make a difference.
First be careful with my solution. Anybody can join on your device, if they have your IP and Port. It might be not the best solution, but it works pretty good.
So what I did is, I've set a DynDNS to my router, so that I doesn't have to change the IP in my script every time. You can get a DynDNS from your provider or you can use the free service No-IP. Next I set a static local IP adress to my arduino/pi via the settings on my router. Then I also set port-forwarding to the arduino/pi.
Then you should be able to access your arduino/pi via the internet. And if you have this, you can also control it via any website you want.
To accomplish an HTTP request in PHP, there will be a lot of possible solutions. But I prefer this:
$response = file_get_contents(YOUR_DYNDNSIP_AND_PORT)
https://www.w3schools.com/php/func_filesystem_file_get_contents.asp
You also can additionally can get a response via this function.
To protect your own network, you can use HTTP Basic Authentication, which you have to add a username and a password to the request. This make it difficulter to access your arduino.
I hope this might help you.
Related
Let's say that I have a website somewhere over the internet. At my house there is a raspberry pi.
Can I send data from that website to that raspberry pi?
I have web server on that raspberry pi, and I tried sending a POST request from website, and it worked, but now anyone, who knows how to send POST request can just send that data to raspberry pi. I want to send that data to C++ program, that I'll write. How can I do it?
Can I do it another way, or somehow secure that POST request?
If you want to prevent your users from seeing that is being posted to the RasPi and from tampering with it, you'll need to send that data from the server, not from user's browsers. You can still do this by POSTing to some sort of web service on the RasPi, or you can cache the information on the web server and poll it from the RasPi. In either case, you should protect that flow by requiring that it take place over HTTPS (as opposed to plain-text HTTP) and authenticating the client using either a TLS client certificate or some sort of API key.
Use SSL (secure transmission) - not perfect but will stop a lot
Use a 'nonce' (https://security.stackexchange.com/questions/30519/prevent-cross-domain-form-submission-with-nonce plus google).
Filter requests not coming from the correct IP address (assuming your web server will have a fixed outgoing IP address). [Side note: this is fakable so not perfect]
Individually encrypt each instructions manually, including a shared private key on your webserver and a unique ID embedded in each message. If you get exactly the same encrypted message it's a repeat post can be safely be dropped.
Is it possible to use the facebook api like we do it on sites live on the internet , but on XAMPP ( a local server) installed on my computer ? I'd really appreciate your feedback.
Mostly the API's should work fine unless you have a registered domain associated with the API app key.
You have not specified which API you are using [Facebook has a lot of API's with various security levels]
A few disadvantages on working on local machines are as follows
A local machine is identified as an anonymous request coming from some IP as its not associated with a domain. Therefore chances of blocking your API request are high.
Your system may have imposed firewall rules for incoming and outgoing requests, if your local server is not configured to send and receive outbound requests your might be in trouble.
Hope this helps.
This is sent from a mobile, don't ask me how but the comment system doesn't work nicely for me.
A local server is the same as a live website, the only difference is that you run it locally...
If you have an internet connection while running the server, you're basicly the same as every other server....
but well if you don't have internet on it don't expect it to be working....
[but ofcourse you can only connect to it locally and not from other computers xD]
I hope I answered your question now, Feel free to add a comment if you want to.
Yours sincerely,
Mike M.
Yes you can. Just make sure that redirect url must be the url which we put in the facebook while building the app.
I have been working on a cross-platform mobile application using Phonegap. I am storing/receiving user’s/other’s location every 10 (ten) seconds using jQuery, Ajax, POST, PHP, phpMySql. I have been testing this exhaustively on my computer, Android and iOS devices.
Suddenly it stopped working. When I checked the location/website where files/database are hosted, it’s showing ‘Access denied. Your IP address [XXX.XXX.XX.XX] is blacklisted. If you feel this is in error please contact your hosting providers abuse department.’. My website is hosted on JustHost. There is no IP address added in IP Deny Manager.
So, it was working on my phone (or other devices) on Mobile data but not on Wi-Fi.
After some times it started working normally. What could be reason for this? This gives me scary thoughts. What if app user’s IP address also get blacklisted? Why did it happen? Have I done some thing wrong? Or is it due to some other reasons?
The server may think that this dDos attack.
In addition, a large number of post requests very heavy load server.
You can use websocket protocol and nodejs. This is the best solution. For example see the socket.io library (http://socket.io/).
I am trying to find the IP address using as3 in adobe Flash professional cs5.5 and I think it is not possible from AS3 without using any server side technology(maybe I am wrong).
But I don't know any server side technology like PHP..etc.
Can anyone provide an example?
you can get the Local Machine using JavaScript. and also you can develop server side script which will retirve your local machine IP address from request header.
But as per your comments on your question I think you required your local machine IP. it will be get using javascript. But this IP address is not gateway or server side displayed one. Because in home or some fire wall / proxy user has different IP to access internet and local mahcine ip will be LAN IP.
and Javascript code you can call using the External Interface.
Please search for Javascript and ExternInterface code example you will find out many code example through google.
There's a simple and clean way to dynamically get the domain name, but not the IP, of the server hosting the SWF file.
You can use the domain property of the LocalConnection class.
try:
import flash.net.LocalConnection;
var lc:LocalConnection = new LocalConnection();
trace(lc.domain); // Outputs domain name of the hosting server, or `localhost` if ran locally.
I have a computer on a small network, so my ip is 192.168.2.100.
I am trying to get my real ip. I download the no-ip client but that just seems like a lot of trouble for such a simple thing.
I created this php script that got http://www.ip-adress.com/ page and retrieved the ip it gave me.
Is there a simpler way? Either using C, WSH or something. Or if there is an easier way in php please tell me.
When I get the ip I'll uploaded it to my ftp site so that I can see the ip from work.
No, there's not really an easier way. Your computer really doesn't know the public IP it's behind -- there could any number of layers of NAT between it and the public internet. All it knows is that it receives messages at 192.168.2.100, and sends outgoing messages through the gateway at 192.168.2.1. It has no idea what happens after the packet hits the gateway.
Do note reinvent the wheel, there is a standard protocol, STUN (with already existing implementations), just for that. See also Discovering public IP programatically.
Not quite what you asked for but still applies to what you want. I setup a GMail Notifier on my home computer and go to the account activity page to see which IP address is accessing my Google acount. Secure, simple and works.
If you want to get the eventual IP that the remote site seems when processing your traffic then the only way is to actually access a remote site. In many situations your computer may not be aware that the IP is getting changed by a proxy or a NAT server.
I always use curl http://whatismyip.org to get my public IP while behind NAT.
You can also access this page to get your IP
http://www.biranchi.com/ip.php
Some routers can tell you their external IP address via UPnP, or more specifically, the IGD protocol. If you happen to own an UPnP enabled router, you can try this. IStaticPortMapping::get_ExternalIPAddress sounds promising.
SNMP enabled devices can tell you their IP addresses, too. The OID to ask for is IP-MIB::ipAdEntAddr.
When I need to check my public ip address, I like this website:
http://www.whatismyip.global/
The website keeps a history of your IPs. For me is very usefull!
The way you're doing it is probably as good as any.
You say you have a public FTP site -- do you also have a web site there? Your other option is to have your local machine access a php page on that public facing site. That php page can verify it's you and then use the $_SERVER['REMOTE_ADDR'] to record your external IP.
Unfortunately, you're server will most likely be completely oblivious to what it's own External address appears to be (as it might be set further upstream via some router/gateway)
You could have a look at this link
http://ip-address.domaintools.com/myip.xml
It might be a little easier to parse than what you're currently doing.
I can't think of how you would resolve your IP address from the perspective of another machine. Here's a couple thoughts:
Automate the loading of the
ip-adress.com page and parse it
Look at DynDNS
Your computer has no information on any NAT or routing that takes place between it and the internet except which hop is the next one (usually your router's internal ip). It simply doesn't know at which hop the internal address gets translated into which public address.
Therefore there is no simple function or method you can call, in any language.
The only two ways are to ask someone else. How?:
Ask your NAT router (because it itself does the translation to a public ip) by fetching and parsing the right page on your router's admin site. Arguably most reliable, and fair.
Ask an external host how it sees you, by fetching and parsing a public service such as http://dynamic.zoneedit.com/checkip.html. An example in VB script is here.