Send url to door ip intercom

previously sent:

hello i have enjoyed and learned a lot from your videos, i have one question, i created a single app with one button to unlock the door , the buttion should run url http local ip address , can you please help me in the code need to press the button and triger the door ?

This is the link that I want to send after clicking the button on the app and it should return a massage either suces or fail and will trigger the door relay to open

http://userid:password@192.186.1.128/cgi-bin/ConfigManApp.com?egs&output1=OUT1_SOS

The above url I could paste it on a browser and it will unlock the door, I want to make it much easier and have my own app that once I click the button it will unlock the door. The intercom is an ip door bell

Regards
Khalid Almansour

I think its easily doable just by using alamofire and just put your url there directly… You. Might need to be connected to the same network for it to work though not sure how it works

thank you so much Sir , I will try it now and get back to you with the result

Best Regards
KAM

check out our small article about it maybe it can help Alamofire Tutorial with Swift (Quickstart)

Greetings;

Thank you so much, it did work

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}
@IBAction func TestUrl(_ sender: Any) {
   
    let headers: HTTPHeaders = [ .authorization(username:"admin", password: "admin"), .accept("application/json")
    ]
    
    AF.request("http://headers@192.168.100.128/cgi-bin/ConfigManApp.com?egs&output1=OUT1_SOS", headers: headers).responseJSON { response in debugPrint(response)}

}

two things I will be working on

first I will try to get a popup message when I press the button, either success or failed.

the second I need to configure port forwarding on my router, so I can open the door from outside my home network.

one question I have, is once the commend processed, do I need to stop the program?

again thank you very much for the help and support

best Regards
Khalid Almansour

Greetings Sir;

what is the best way to send a message to the user that it is a success action (Code 200), or request is not completed?

Use any kind of alert, show an alert that’s good or bad to the user after the request