Let $$I(u):=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+\cos(u)\,\cos(t)\big)^2}\,.$$
Note that $I\left(\frac{\pi}{2}\right)=2\pi=I\left(\frac{3\pi}{2}\right)$, which agrees with the formula $I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}$ for $u\in\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$. From now on, we assume that $u\in(0,2\pi)\setminus\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$.
Let $z:=\cos(t)+\text{i}\,\sin(t)$; then,
$$I(u)=\oint_\gamma\,\frac{4\,z}{\text{i}\,\left(z^2+2\,\sec(u)\,z+1\right)^2}\,\text{d}z\,,$$
where $\gamma$ is the positively oriented unit circle $\big\{w\in\mathbb{C}\,\big|\,|w|=1\big\}$. That is,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\oint_\gamma\,\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,\text{d}z\,.$$
Write $u_+:=-\sec(u)+\tan(u)$ and $u_-:=-\sec(u)-\tan(u)$. Define
$$f_u(z):=\frac{z}{\big(z^2+2\,\sec(u)\,z+1\big)^2}=\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,.$$
You can write $$(z-u_+)^2\,f_u(z)=\frac{z}{\left(z-u_-\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_+}\,\big((z-u_+)^2\,f_u(z)\big)=-\frac{u_++u_-}{(u_+-u_-)^3}=+\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
Similarly, you can write $$(z-u_-)^2\,f_u(z)=\frac{z}{\left(z-u_+\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_-}\,\big((z-u_-)^2\,f_u(z)\big)=-\frac{u_-+u_+}{(u_--u_+)^3}=-\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
If $u\in\left(0,\frac{\pi}{2}\right)$, then $u_-<-1<u_+<0$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{\pi}{2},\pi\right)$, then $0<u_+<+1<u_-$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\pi,\frac{3\pi}{2}\right)$, then $0<u_-<+1<u_+$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_-}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{3\pi}{2},2\pi\right)$, then $u_+<-1<u_-<0$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
In all cases,
$$I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}=2\pi\,\left|\text{csc}^3(u)\right|\text{ for all }u\in\mathbb{R}\setminus \pi\mathbb{Z}\,.$$
In general,
$$\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\sin(t)\big)^2}=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\cos(t)\big)^2}=\frac{2\pi}{\big(\sqrt{1-r^2}\big)^3}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$. Similarly,
$$\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\sin(t)}=\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\cos(t)}=\frac{2\pi}{\sqrt{1-r^2}}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$. Here, we pick the branch of $\sqrt{1-r^2}$ in such a way that $$\big|1-\sqrt{1-r^2}\big|<|r|$$ (i.e., the branch cuts are $(-\infty,-1]$ and $[+1,+\infty)$). That is, for $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$, the complex number $\sqrt{1-r^2}$ is in the open half-plane containing complex numbers with positive real parts; in short, $$\text{Re}\big(\sqrt{1-r^2}\big)>0\text{ for every }r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)\,.$$
Best Answer
Hint: integrate your sum term by term. If you want to compute it in a more direct way, write $\cos(z) = \frac{1}{2}\left( e^{iz} + e^{-iz}\right)$ and integrate directly. For yet another way, utilize Cauchy's integral formula.