How to display webpage from get request with javascript - rest

I am new in working with get and post requests. I have the challenge to display an webpage which uses javascript. The workflow is to send an get request with some headers. If everything is correct, the server is returning the requested website (which needs javascript). What is the best way to implement a solution for this? Is it possible to realize this with c#? Has anyone any keywords / tips? Thanks in advance!

Related

Delphi REST Debugger Returns Error 429 Too Many Requests but Browser Returns JSON as Expected

What is the difference between the way a browser calls the URL and doing it via Rest Debugger or HTTP Components?
I have a 3rd party Web REST API that work every time in a browser (IE it returns JSON as expected), but when I use (GET) the same URL in the Delphi REST Debugger it returns error code 429 Too Many Requests.
I am not allowed to post the exact URL here (I'm sorry, boss has the last say but it is like this https://xxxx.yyyy.com.au/search/resources/store/zzzzz/productview/123456).
For additional information the result is consistent giving the 429 error when I use NetHTTPClient and NetHTTPRequest components as well as using the Delphi REST Components.
I thought that setting the user agent to be the same as my browsers might help, but alas it didn't. I use Delphi 10.3.3 Rio
I'm a bit new to REST and haven't found an answer by googling for a couple of days now. Any help will be most appreciated.
Thanks,
John
The answer is cookies. When I rejected all cookies I could see the behavior as stated by #RemyLebeau where the page is in a continuous loop. The browser sends a cookie with the request header. I'm new to all of this, so I'll try to replicate what the browser is doing and see what happens. If I get really stuck I'll post another question specifically about cookies. Many thanks to all who offered advice. Most appreciated. I put this here because someone deleted this as an answer.

Is there a quick way send post requests?

i want to test a small php script i wrote, which accepts POST requests..
but is there a way to test it without writing a html form.
Im trying to do this using simple rest client chrome extension. But I'm not sure how to do POST request in it.
By using Advanced REST Client, you can send a POST request in which the data can be stored as form data (probably the simplest).
Just click the second Form tab when entering the application, and you can specify key-value pairs.
Here is an image of the application.
I use a very nice Chrome extension for this: REST client or similar. Look in the chrome market, is plenty of tools.

How can one learn to use the twitter API?

Ok before you jump to some conclusion like I'm looking for a free lunch or something of the sort, read the description entirely.
I have experience only in making small simple apps in PHP, Java and ASP.NET. I had no idea what GET, SET etc exactly are and what REST services are. To try to use the Twitter API, I did some reading and got to know (I might be wrong here, because this is what I THINK that I know..) that you can make a GET request like this one:
http://api.twitter.com/1/statuses/user_timeline.json
Using, say, cURL (I haven't tried it yet), and you get a JSON object returned which contains the statuses on your timeline in a certain format. And I verified this from here
But I don't understand how does Twitter know that it is ME and return only MY data? Where am I sending my account details?
What I want is for the use to come to my website, click a button to give my application the permission to access his/her Tweets and I do some processing in PHP and display the output. But I don't know where do I start from?
I am not asking you to give me bread, I'm asking you to tell me what should I do to learn to fish?
All tutorial I have been following till now have been sort of spoon fed where they say things like 'Download this php file from our site, include it in your source file, use this method to do this and that method to do that.'
This one is a change for me, so does anyone have any pointers? Is there any reading that I should do or approach that I must follow to learn that I'm doing wrong?
EDIT : I know there are 3rd party libraries out there and it might be easier to learn to use those, but I want to have an idea of how the people who made those did it.
To use Twitter (at least its REST API), you had better to read tutorials about the following things :
REST architecture because it is how Twitter communicates with your application.
HTTP requests. Useful for Authentication of requests (HTTP headers), kinds of HTTP requests (GET and POST for the Twitter API) and return codes of requests.
OAuth which is the protocol used by Twitter for authenticating requests.
Format of datas returned by Twitter after the requests. Most of the time it is JSON but it can also be like in a URL query string (for OAuth authentications). You are lucky because before there were XML and Atom (for RSS feeds) too.
And of course the Twitter Documentation to know how they use all that stuff, how they know that is YOU with THIS application (request authentications) and to know the objects manipulated by the API (mainly tweets, users and timelines).
Good luck for it !

REST and Building Forms that Redirect

I'm build an application along RESTful principles. I have a user-facing form that POSTS to create a new comment, the URL for that action is POST {article}/comment
After the POST happens, I want to redirect the user to GET {article}/thanks
But I'm not sure how to implement this. It seems un-RESTful for the POST {article}/comment resource to also have the logic knowing about the next step for the underlying {article}
Any thoughts? Thanks!
You should consider applying AJAX principles to submit your form, receive a success/fail/other response from the server, and to take further action (redirect) based on that response.
You will find a lot of help using some frameworks like jQuery that will help posing your form and process responses, take a look at this blog post, especially its consume part.

Testing oAuth / facebook authentication with WebTestCase in Symfony2

I'm trying to get a FacebookLoginTest running.
Problem is: the Symfony2 client does not send real HTTP requests, so it does not work on URLs of other services (like facebook).
I know I could work with cUrl,... but I see so many obstacles there: session, javascript, redirects.
Any ideas how we could get this running? Anyone got a automatic oAuth test running?
Your best bet might be Goutte https://github.com/fabpot/Goutte which is a wrapper around the Sf2 components you're using combined with an HTTP client. Good luck!
curl should work just fine for this, and while it doesn't support javascript, you won't need js support for what you're trying to accomplish.