Call the image T, a subspace of S. Since the domain is compact and the range is hausdorff, T is closed. Its intersection with every edge is closed. Suppose an intersection includes p, but does not include points on either side of p. This is a disconnected region of T. However, the image of T is connected, so this can't happen at all; or else all of T fits in one closed portion of the interval. In any case, we only need introduce at most 2 new endpoints to indicate where T starts and/or stops along the interval. Make this refinement for every interval, and T becomes a subcomplex of S. In fact we can consider T on its own, as a 1 complex.
Since T is the image of a compact set it is compact, and requires finitely many cells. Thus T is a finite cw complex.
Suppose T contains a cycle, in the graph theoretic sense. Pull the vertices back, through f, to the sphere. (Choose any point in the preimage of each vertex; it doesn't matter.) Let a chain of arcs in the sphere pass through these points, and define a cycle, as a graph, and in homology. Since the sphere is simply connected, this is 0 in h1. Apply f, and the induced homology homomorphism must take 0 to 0. Thus the chain of arcs in T becomes 0 in h1(T). Compute h1(T) using the cellular boundary operator. Our cycle is indeed a cycle, and there is no boundary from above, hence this is a nontrivial element of h1. This is a contradiction, hence T has no cycles, and is a tree.
Select any vertex as the root, and retract all of T onto its root. (This is where we need T to be a finite cw complex.) The resulting function, which is in the same homotopy class as f, maps the entire sphere onto a point. Finally, since S is connected, any point can slide along to any other point. There is but one homotopy class of the sphere, and it is trivial.
The same result holds for pointed spaces. Make sure the image of the base point of the sphere becomes a vertex in T, and make it the root of the tree.
Let S be a 1 complex. Let p be a point in S. If p is part of an edge, the edge containing p is an open path connected set. If p is a vertex, bring in all the open edges incident to p and find an open path connected set. Therefore S is locally path connected. The components of S are the path components of S, and we may as well analyze them one component at a time. Therefore, assume S is connected.
We know that h0 = Z. Since there are no 2 cells, h2 and beyond is 0. We only need evaluate h1.
Let T be a spanning tree for S, and build the cycle basis. This is generated by the chords of S, i.e. the edges of S that are not in T.
Let r be any vertex of T, which will act as the root of the tree. Let a path start at r and connect to any other vertex in T. This path is compact, and touches finitely many cells. Every point of T is finitely many steps away from r. Use this to contract T onto r. For the first half second, all the edges adjacent to r contract linearly onto r. Vertices that were one unit away from r now coincide with r. Repeat this step, moving twice as fast. Now everything two steps away hass been pulled onto r. Contract again and again, geometrically faster, so that after one second all of T shrinks down to r. As the spanning tree shrinks to a point, Each chord becomes its own loop. This retract of S has the same homology, and the same homotopy classes. Therefore h1 is a free Z module, with each loop acting as a generator. Similarly, π1(S) is the free group with these loops as generators.
Remember that the retraction is an isomorphism, in homology or in homotopy. So in the original complex S, the cycle basis, running through the spanning tree, generates π1 and h1.
π1(S) fairs no better. Label the chords of S as A B and C. Build a cycle basis: A+B, B+C, and A+B+C. This time the algebra is noncommutative. The first generator becomes AB in the free group of S, not BA. Let the generators be AB, BC, and BAC. After some trial and error, you can show that A is not accessible from these three generators. (You can find a more formal proof here.) Our alternate cycle basis spans a proper subgroup of the fundamental group of S.