How to view the raw XML or Json response using LinqToTwitter? - linq

How can I view the raw XML or Json response when doing a search for users using the LinqToTwitter library? I'm using the SingleUserAuthorizer for oAuth.
If you have any ideas using other libraries or even a simple oAuth framework, I'm open to suggestions.
Thanks.

TwitterContext has a RawResults property you can use.

If this is just for debugging purposes, I'd use Wireshark or Fiddler - that way you get to see the complete HTTP requests/responses.

Related

Structure of amadeus api https

usualy when I use API's I paste the entire url in browser and it print it out json format using json pro extension in chrome. Like this is a lot easier to copy the path of some data and render it to the page.But my problem is I don't know structure of https. I am not sure where I have to insert the key and secret code. In command line I print all data but I cannot get the path of specific data without using json probextension. Help please. Thank you
I recommend to read the following article:
https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262
and later, review the following repository, you could tinker with the curl request here:
https://github.com/amadeus4dev/amadeus-code-examples
https://github.com/amadeus4dev/amadeus-code-examples/blob/master/airline_code_lookup/v1/get/curl/airline_code_lookup.sh

Ruby tests with spec and capybara xml post

I am trying to figure out how to send a xml http request (validated by request.xhr?) using page.driver.post() method.
Have you any suggestions? Running out of ideas :(.
Thanks a lot
If you're doing XML http requests then you're doing API testing which you really shouldn't be using Capybara for.
I got it, it is possible to pass it like this.
page.driver.post("/",{"HTTP_X_REQUESTED_WITH" => "XMLHttpRequest"})

Response rendered as json in IE for browsable apis

On IE when i try to browse the rest apis, i am getting a application/json response instead of api (text/html) response (Returns html response on firefox). I am using django restframework 2.2.5 for this purpose.
I read through the documnets and understood that in order to overcome the problem of broken headers for IE we need to use TemplateHTMLRenderer explicitly in the view, so i have added the following to the class definition of my view but still i am getting a json response. Am i not doing it correctly or i am missing something else?
class CustomReports(generics.GenericAPIView):
`renderer_classes = (renderers.TemplateHTMLRenderer)`
Can you please help in fix the problem so that i get html response in case of IE as well?
Which version of IE are you using? I believe newer versions of IE should send correct Accept headers.
I probably wouldn't bother trying to fix things up to work around IE's broken behavior, but instead just make sure that you're including format suffixes in your urls. Then you can simply use the .api suffix to see the browseable API, or the .json suffix to see the plain json.
Eg instead of http://127.0.0.1:8000/api-root/, use http://127.0.0.1:8000/api-root/.api.

How to view GET request headers generated by open-uri

I'm using open-uri and I know I can get the response headers with the meta method as below, but I'm wondering how I can view the GET headers generated. Or would I have to use a different library for this?
page = open('http://www.google.com');
page.meta
Thanks for the help
You can set the request parameters with open('http://example.com', 'User-Agent' => 'Me'), but to see all the headers that will be sent you will probably have to sniff the traffic with a proxy, ngrep, or tcpflow. Or read the source.
open-uri is a convenience library for quickly fetching and reading files over a network. If that's not your use case, you can use a lower-level library like Net::HTTP to get more control over the connection.

any gem available that will pull out the get and post parameters ofsource code that I've got using net/http?

I am pulling the source code of a webpage using net/http and I was wondering if there was anyway to parse out the get and post parameters so that they can be listed?
Thanks,
Tom
GET and POST parameters are in the HTTP header, not the HTML source. So the answer is no, you can't get it from the source, unless you know that the information has been somehow encoded in HTML, or can do that yourself.
However, any GET or POST parameters would have been sent by your Net::HTTP code, so you can print those out yourself.

Resources