I need to generate RSS feed and get title and urls of the posts and so on. I decided to use Superfeedr for it. So in this situation, I'm a subscriber in Superfeedr. There is callback (the subscriber URL) field to get data, but I don't know what should be written in callback file. I researched the net for example code, but I found nothing about example code. BTW, I want to do this process in PHP. So if you know what should I need write to this file, please comment.
John, I think you got it... which is good. Now, what to write in your PHP: this callback url (your PHP file) will be called in 2 different cases:
to verify your intent (to confirm that you want to subscribe)
to notify you of new content.
I'm no PHP person, but I'll dscribe the algorithm for you
To differentiate between the two, you just have to look at the type of request. If it's a GET request, then, it's the verification of intent, and if it's a POST request, then it's the notification of new content.
If it's the verification of content, you just have to echo the hub.challenge provided as a GET param (I believe echo $_GET['hub.challenge']; should work). You should also verify that you really want to the subscription, but that the logic of your app and I don't know it (most people just look up the $_GET['hub.topic'] in their database and if it's there, echo the challenge. If not, echo something else.
If it's the notification of new content, it's a bit more complex. You have to access the BODY of the HTTP request (again, not sure how PHP does it, but I'm sure somebody can help), then, parse it to extract the title and urls, and handle them as you would want (most people will save that in their databases).
I hope this helps!
I'm using this code in php. Hope it helps someone
<?php
if(isset($_Get["hub_challenge"])){
echo $_Get["hub_challenge"];
return;
}
Related
I'm not sure if I'm understanding what slack means by a post request.
In my experience with what I'm familiar with it's either a curl request POST or with PHP use something like:
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
// get token
$token = $_POST['token'];
}
I'm not receiving anything from Slack though, Is it a cors problem? I tried that I enabled headers. I saw other questions, I can't seem to find much on this topic.
how to handle outgoing-webhook (Slack) using php
Slack outgoing webhook :URL(s)
I selected a channel, I also put in a trigger word, the return text is not related to the trigger word. Maybe by returning the text it's triggering/causing a loop? I just tried that no dice as well. There are no errors in apache, the code itself works, when I visit the link directly on my server it processes the code.
The incoming webhooks are no problem.
I don't understand I've tried this many times could never get it to work what am I missing?
Regarding the headers I wasn't sure what domain to match to, I didn't enable all (the star *) so I tried slack.com but it's possible that's not what slack uses to send out the request.
I am also learning on this, and there's not much documentation anywhere. I tried it yesterday. I sent a text with trigger words like "try send abcd". Based on the posted data to my public URL it will match the trigger word try with text "try send abcd". This text will be posted to the URL I provide in configuration and I catch the posted data like what's slack described in their docs with api response json raw body.
Anyway, the channel and url provided must be public and you need to provide a trigger words too. what's the posted data sent to your URL?
So far that's what I can do. I also plan to fetch them via js fetch(). if you've got any information on this kindly share it with me :)
My question maybe unheard of or may even be impractical.
But, I believe it is practical and acceptable.
Problem: PHP request and response in background thread.
Problem constraints:
You know it uses POST method.
It has two fields fname and lname as html ids that need to be filled.
You get response in the same page i.e. index.php .
Pseudocode to solve the problem:
Open the website in background. Something like openURL("xyz(dot)com");
Read the data sent in html format.
Change the value of the fields fname and lname to required fields "Allen" and "Walker."
Now, submit the fields back to the server. ( Page has a submit button.)
Note: PHP code has a standard if-else check to check for those values. If the field is properly set, it then says "Success" else "Failed"
Again, get the response sent by the server.
Check if "Success" was returned.
If "success" was returned, UPDATE UI thread for saying "JOB done".
Else, "Job failed."
Note: I am not talking about using a WebView. Everything happens via a service or AsyncTask.
Now, this is a simple question, and any ideas or a direction is acceptable.
So, to recap. You have to open a webpage in background, change its field, submit it back and then get the response.
I know we can open a website and get its content. But, I would also like to know if what I said is possible or not. And, I know it is possible. And, that I only lack the knowledge on Java Web API, could you please guide me on this.
Thank You. And, Have a Good day!
use this link for best solution of calling web service without using WebView.
In this example fname and lname sent in namevaluepairs we get responce in json formet and parse json and get data also json parse defined in examples.
What you are trying to achieve is to create a webservice call using a AsyncTask.
Like you have mentioned, you can make a post request within the AsyncTask, passing in the variables required for the request.
You can find a good example as shown: Sending HTTP Post Request with Android
Ok this is quite complicated and not even sure if it is possible. Need some insight from knowledgeable people to advise on how I should proceed.
I need to process a form on a remote site, screen scrape the results (on the fly), parse the information and display it back to the end user.
--More clearly explained by example--
1 my site is -> sitea.com
[2] the form is on -> somebodyelseswebsite.com (no DB access, but form is public)
Here's my logic:
i can replicate the form from site [2] and make an exact copy on my site1.
when the user submits the form i need some kind of object in the POST (javascript?) that will assign the users input to ... and process the form on site [2], screen scrape the results, and return the data in an array, which i can display on my site1.
key points:
The user must not be aware of the transaction with site[2].
This must happen in real-time and fast
So can this be done? If YES, How? I know about PHP cURL can I use only PHP or do I need to use something else?
--further clarification--
Yes, this can be done. cURL is one way to do it, yes. You need some pretty heavy error-checking and validation for any sort of reliability though. You'd use a cURL POST (assuming the remote host doesn't have any sort of form key, ip block, referer checking, etc.) to replicate the behavior of that form's fields. Then you'd need to scrape the return and I think that's the difficult part.
For me, I'd use a DOM Parser to get very specific. Here is a post on how to do that.
This should be a fairly simple question. Essentially, I believe there's a good chance I'm simply brainfarting.
I'm trying to implement a transaction with Authorize.net using the AIM method and I was unsure if I should have a page where the user adds all of their information and card, etc, and have that post to another page that does the cURL and response, etc., or if that's bad practice and I should have it all on one page.
That's basically the simple question, but I can NOT find any implementation docs or decent examples. The only one I can find has all of the info hard coded into the page and does the cURL and response stuff on the same page, which doesn't answer my question!
John Conde (whose posts around here a lot on these questions) has some documentation available here which I found to be really helpful.
You can do it on the same page, meaning the form, and the cURL call both on checkout.php. Check for the $_POST variable being set, if it isn't show the form, the destination will be checkout.php (make sure you use HTTPS). If $_POST is set, then make your call to authorize.net via cURL, parse the response, and show the customer a success or fail message.
How do I encode a URL or hide confidential information from being displayed in the browser?
For example, I have the following link:
<a href="path/profileId/<?php echo $this->data['profile_id'];?>Edit</a>
I don't want profileId to be displayed in the browser.
Is there any function or method in Zend or PHP to accomplish this task? I am newbie in Zend so I have no idea if there is even a template which provide such functionality.
I suppose you will need the ID in some form or another on the /path/profileId/ page, otherwise you won't know which profile to display, right? If that's the case, it's impossible to completely hide it.
You could use a POST request instead of a GET request so the ID won't show up in the URL, but it'll still be visible in the HTML and the request body if you know where to look.
The real question is, why is a profile_id confidential to begin with? If somebody is able to do something bad just by knowing an identifier, your system has a huge problem.
You could of cause encrypt the information before sending it and decrypt it on the receiving end, but that seems pretty nonsensical. The typical way would be to simply pass tokens that are by themselves worthless, but allow you to resolve the real data on the backend. The prime example of this is a Session, another is passing the ID of a record and retrieving the related record, including confidential information, from the database.
You can use obfuscation for it. XOR the ID befor echo it out, XOR it back when handling the GET request.
But you should have access controls anyways, is this user allowed to open this link ?