Session Ready
Exercise

Using user agents

As discussed in the video, informative user-agents are a good way of being respectful of the developers running the API you're interacting with. They make it easy for them to contact you in the event something goes wrong. I always try to include:

  1. My email address;
  2. A URL for the project the code is a part of, if it's got a URL.

Building user agents is done by passing a call to user_agent() into the GET() or POST() request; something like:

GET("http://url.goes.here/", user_agent("[email protected] http://project.website"))

In the event you don't have a website, a short one-sentence description of what the project is about serves pretty well.

Instructions
100 XP
  • Make a GET() request to url.
  • Include a user agent that has a fake email address "[email protected]" followed by the sentence "this is a test".
  • Assign the response to server_response.