How to find $\int_0^{2\pi} \frac{dt}{1+2\cos(t)}$ The problem is
$$\int_0^{2\pi} \frac{dt}{1+2\cos(t)}.$$ I know it is equal to 
$$\int\limits_{|z|=1}\frac{2dz}{i(1+z)^2}$$
but I don't know how I should calculate the last integral.

If you write
$$
\begin{equation*}
z=e^{it}\qquad \left( 0\leq t\leq 2\pi \right), 
\end{equation*}
$$
since
$$
\begin{equation*}
\cos t=\frac{z+z^{-1}}{2},\qquad dt=\frac{dz}{iz},
\end{equation*}
$$
the integral takes the form
$$
\begin{eqnarray*}
\int\limits_{|z|=1}\left( \frac{1}{1+2\frac{z+z^{-1}}{2}}
\right) \frac{1}{iz}dz &=&\int\limits_{|z|=1}\frac{1}{i}\times 
\frac{1}{z^{2}+z+1}dz \\
&=&\int\limits_{|z|=1}\frac{dz}{i\left( z+\frac{1-i\sqrt{3}}{2}
\right) \left( z+\frac{1+i\sqrt{3}}{2}\right) }
\end{eqnarray*}
$$
and not
$$\int\limits_{|z|=1}\frac{2dz}{i(1+z)^2}.$$

Since $\cos \frac{2\pi }{3}=\cos \frac{4\pi }{3}=-\frac{1}{2}$, hence $1+2\cos \frac{2\pi }{3}=1+\cos \frac{4\pi }{3}=0$, the given integral has singularities at $t\in\{\frac{2\pi, }{3},\frac{4\pi }{3}\}$. We thus split it as follows:
$$
\begin{equation*}
\int_{0}^{\frac{2\pi }{3}}\frac{dt}{1+2\cos t}+\int_{\frac{2\pi }{3}}^{\frac{4\pi }{3}}\frac{dt}{1+2\cos t}+\int_{\frac{4\pi }{3}}^{2\pi }\frac{dt}{1+2\cos t}.
\end{equation*}
$$
Each integral is a divergent improper integral of the second kind. Using the Weirstrass substitution$^1$  $x=\tan \frac{t}{2}$, for instance the first integral becomes
$$
\begin{eqnarray*}
I_{1} &=&\int_{0}^{\frac{2\pi }{3}}\frac{1}{1+2\cos t}dt,\qquad x=\tan \frac{t}{2} \\
&=&\int_{0}^{\sqrt{3}}\frac{2}{\left( 1+2\frac{1-x^{2}}{1+x^{2}}\right)
\left( 1+x^{2}\right) }\,dx \\
&=&\int_{0}^{\sqrt{3}}\frac{2}{3-x^{2}}\,dx,\qquad x=\sqrt{3}u \\
&=&\frac{2\sqrt{3}}{3}\int_{0}^{1}\frac{1}{1-u^{2}}\,du \\
&=&\left. \frac{2\sqrt{3}}{3}\operatorname{arctanh}u\right\vert _{0}^{1}=\infty .
\end{eqnarray*} 
$$
--
$^1$ The Weierstrass substitution is a universal standard substitution to evaluate an integral of a rational fraction in $\sin t,\cos t$, i.e. a rational fraction of the form 
$$R(\sin t,\cos t)=\frac{P(\sin t,\cos t)}{Q(\sin t,\cos t)},$$
where $P,Q$  are polynomials in $\sin t,\cos t$ 
$$
\begin{equation*}
\tan \frac{t }{2}=x,\qquad t =2\arctan x,\qquad dt =\frac{2}{1+x^{2}}dx
\end{equation*},
$$
which converts the integrand into a rational function in $x$. We know from trigonometry (see this answer) that 
$$\cos t =\frac{1-\tan ^{2}\frac{t }{2}}{1+\tan ^{2}\frac{
t}{2}}=\frac{1-x^2}{1+x^2},\qquad \sin t =\frac{2\tan \frac{t }{2}}{1+\tan ^{2}
\frac{t }{2}}=\frac{2x}{1+x^2}.$$
