Stake and Ward API

5 postsstarted by tjallred 4,240 viewsoriginal topic

New Member
#1
I'm creating a website geared towards members of the Church that would
allow registered users to optionally specify their Stake/Mission and Ward/Branch.

Is there any sort of web service (REST/SOAP/XML/screen scraping) that I could use to let users pick their stake/mission and ward/branch?

Trevor
Senior Member
#2
tallred wrote:I'm creating a website geared towards members of the Church that would
allow registered users to optionally specify their Stake/Mission and Ward/Branch.

Is there any sort of web service (REST/SOAP/XML/screen scraping) that I could use to let users pick their stake/mission and ward/branch?

There is no API.

The only thing I can think of is that you could make the user enter their LDS Account username and password, and log them into LUWS. Technically you then could scrape the screens to harvest the names of their units.

If all you do with the harvested data is handled client-side, that might be okay policywise. But I think harvesting anything from LUWS and storing it on your server would be coloring outside the lines.
Community Administrator
#3
I'd be leery about giving my LDS Account information to a non-church server. I'd have no idea what's being done.
Have you searched the Help Center? Try doing a Google search and adding "site:churchofjesuschrist.org/help" to the search criteria.

So we can better help you, please edit your Profile to include your general location.
Community Moderators
#4
Not exactly an API, but you could bounce the user-supplied info off of HERE to get the actual links to their stake/ward websites.
So we can better help you, please edit your Profile to include your general location.
New Member
#5
I'll have to change this as soon as the Church changes their search screen, but it works for now. Thanks Mikerowaved for the idea.

Code:

public class ScreenScraper {
	private static String LDS_SEARCH = "http://www.lds.org/units/find/search/1,16055,2311-1,00.html";
	
	static public List<Account> findStakes(String unitName) {
		List<Account> results = new ArrayList<Account>();
		
		String url = LDS_SEARCH + "?unitName=" + unitName;

		Source source = null;
		try {
			source = new Source(new URL(url));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (source == null)
			return results;
		
		List<Element> allElements = source.getAllElements(HTMLElementName.A);
		for (Element element : allElements) {
			String link = element.getAttributeValue("href");
			Account account = new Account();
			account.setName(element.getContent().toString());
			account.setDescription(link);
			if (link.contains("secure.lds.org/units/stake")) {
				account.setType(AccountType.Stake);
				results.add(account);
			}
			if (link.contains("secure.lds.org/units/home")) {
				account.setType(AccountType.Ward);
				results.add(account);
			}
		}
		
		return results;
	}
}