Hello,
I’m a newbie to Webpushr and the REST API, but wanna see if I can get it to work from my own server.
On the REST API guide page, I was able to acquire my Webpushr Key and Auth Tokens, then I copied the php example script to my local computer, named it “REST-API.php”, then hard-coded the key and token into the script in the locations indicated.
Next, looking at the script, I see the “$req_data = array(” statement, followed by it’s, I presume, keys - ‘title’, ‘message’, ‘target_url’, etc. I see, for instance, the ‘title’ key has as its value, “‘Notification Title’”, and all the other keys are pre-populated with appropriate values.
Thinking I knew what I was doing, I removed the values for ‘title’ and ‘message’, leaving just the quotation marks. I did this, thinking that input statements from a web form should place data entered into the form into the php script where the values used to be. Unfortunately, doing this yielded me the “Missing parameter ‘title’” message. Interestingly enough, though, if I take the script, as I got it from the guide page, put it on my server, and simply replace the pre-defined values, with values of my own, not bothering to actually change the date & time values, I actually get the “incorrect value, Date & Time must be 5 minutes in the future” message. Should I actually alter those values as well, and execute the script, a notification goes out at the appointed time. Here’s the web form, as I have it so far:
—Begin Web Form Snippet –
<form action="https://www.ganahee.com/REST-API.php" method="post">
<label for="title">Notification Title:</label><input type="text" name="title" value="" size="100" title="Give your notification a title, 100 Chars Max">
<br><br>
<label for="message">Notification Message:</label> <input type="text" name="message" value="" size="255" title="Enter what you wish your notification to say, 255 chars max.">
<br><br>
<input type="submit" value="Send Notification!">
</form>
– End Web Form Snippet –
The way I have this form written, I’m thinking it should pass values entered to the appropriate parameters in the php script I reference in my form action.
First: Does the php code have to be inside an actual web page, or can it be placed on the server as a stand-alone script, as I’ve done here?
Second: If parameters can be passed from the form to the script, what the heck am I doing wrong?
In the interest of full-disclosure, I’m not a programmer, don’t know JavaScript, php, perl, or anything like that. I do have a reasonably decent grasp of HTML, and haven’t really gotten my head around CSS, as I’m 100% totally blind, and have been so for 36 years, and had fairly poor vision prior to that. I do enjoy tinkering with this sort of stuff, as a hobby, and find it quite gratifying if I’m able to get things to actually work.
Any help with my issue(s) is welcome and greatly appreciated!