
Hands on teaching you to tune APIs with Curl, the kind with tokens
Recently, some friends asked, using Curl to call the API with authorization is always 403 blocking the way, especially when you need to proxy IP more blind. Today, we will break up the crumbs to say, how to use ipipgo proxy service to pass the API with token stable local.
What is the relationship between a token and a proxy IP?
To give a chestnut, the token is like your home access card, the proxy IP is the courier. The courier to enter the neighborhood (access API), both access card (token) to verify the identity, but also have to take a designated route (proxy IP). ipipgo provides dynamic residential agent, like the courier can be changed at any time, so that the guards (servers) can not see the cracks.
curl -x http://user:token@gateway.ipipgo.com:8080
-H "Authorization: Bearer your_api_token"
https://api.example.com/data
Four Steps to Practice
Step 1: Get the proxy format right
The proxy address for ipipgo looks like this: gateway.ipipgo.com:port number. Remember to spell the account token in the URL, it's like adding sugar to your coffee, anything less won't taste right.
Correct posture
-x http://账号:令牌@gateway.ipipgo.com:端口
The way to write it (don't learn it)
-x gateway.ipipgo.com:port -U account:password
Step 2: Don't leave your tokens lying around
I've seen people pass the token as a normal parameter, isn't that the same as sticking the house key in the lock? You have to use the Authorization header with the Bearer prefix. ipipgo's proxy automatically passes through those headers, solid.
Common Rollover Scene
| error code | what is the meaning? | How do I fix it? |
|---|---|---|
| 407 Proxy Auth Required | Failed proxy certification. | Check that the account token is not written backwards |
| 403 Forbidden | The API doesn't recognize your token. | Go to ipipgo backend to check the remaining traffic |
Veteran Driver Advice
1. Don't be stingy in adjusting the timeout, it is recommended to set more than 30 seconds. ipipgo's proxy IP quality is online, but some APIs are slow to respond.
2. don't fight with the frequency control, changing IPs is better than hitting. ipipgo's pool is big enough to cut IPs every minute.
3. Remember to add the agent status to the log, so that you can quickly locate the problem when it occurs.
QA triple
Q: What should I do if my token keeps failing?
A: 80% is leaked, hurry to ipipgo background reset. It is recommended to use a temporary token, it is safer to use it up.
Q: What should I do if I can't connect to the agent?
A: First ping gateway.ipipgo.com to see if it works. If it is OK, it is likely that the port has been changed to 9021 or 9022.
Q: API response suddenly slowed down?
A: Maybe the current proxy node is blocked. Add -proxy in curl command to replace the new IP, ipipgo's IP pool is deep enough, feel free to change it.
Lastly, using a proxy to adjust the API is like driving a car. ipipgo provides a good car, but the driver must also comply with traffic regulations. Don't make high-frequency requests, legal compliance is the only way to last. If you need a test account, go to the official website and ask the customer service girl for a trial, report the secret code "curl old iron" there are surprises.

