Created
July 15, 2016 06:38
-
-
Save shrutis22/afdb0edf6f851b94f357f802ccd58639 to your computer and use it in GitHub Desktop.
Calls Google APIS to get Google News
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This class exposes methods | |
* that call Google APIs to | |
* get news. | |
* | |
* @author Shruti Sridharan | |
* @since 08/03/2016 | |
* @version 1.0 | |
* @revisons N/A | |
*/ | |
public class GoogleNews { | |
/** | |
* This method calls the Google | |
* APIs with the encoded key. | |
* | |
* @since 08/03/2016 | |
* @version 1.0 | |
* @revison N/A | |
*/ | |
public static String newsGrabber( String searchTerm ) { | |
/** | |
* Gets the Endpoint from the Custom | |
* Settings. | |
*/ | |
String endpoint = Google_API_Setting__c.getInstance( 'Google News Endpoint' ).Value__c; | |
endpoint = endpoint.replace( 'searchstring', searchTerm ); | |
Http http = new Http(); | |
HttpRequest httpReq = new HttpRequest(); | |
HttpResponse httpRes = new HttpResponse(); | |
httpReq.setMethod( 'GET' ); | |
httpReq.setEndpoint( endpoint ); | |
httpRes = http.send( httpReq ); | |
String xmlBody = httpRes.getBody(); | |
return xmlBody; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment