In this paper we use the Homotopy analysis method to obtain an analytic approximation for the entire photon trajectory in the Schwarzschild spacetime. This is usually expressed exactly in terms of an elliptic integral. We compare our approximation with other formulae found in the literature, which were specifically obtained for the Schwarzschild solution. Unlike some of these formulae, our approximation can be applied and maintains a good accuracy for emission point close to the event horizon and also for emission angles close to and greater than π/2\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$\\pi /2$$\\end{document}. We show that our method can easily be applied to other spherically symmetric solutions such as the Reissner-Nordström solution. Such an approximation would be useful when accurate determination of the light trajectories around compact objects is required without the need to revert to time consuming numerical integration of elliptic integrals.