Integration of Google News via Visualforce Page

Google News aims to organize all the world’s news and make it accessible to its users, while providing the best possible experience for those seeking useful and timely news information. But the question is how will you get the Account news dynamically in salesforce. Here is how you can achieve it –

I am sure the below mentioned solution will help lot of non technical system administrators.

In order to bring the Google Maps please follow my previous post –
Integrating Google Maps (GMaps) with Salesforce (Accounts / Leads)

Google News Code –

<apex:page standardController="Account">

<apex:includeScript value="" />
<script type="text/javascript">
    google.load('search', '1');

    var newsSearch;

    function searchComplete() {

        var container = document.getElementById('anthologyGoogleNews');
        document.getElementById('anthologyGoogleNews').innerHTML = '';
        if (newsSearch.results && newsSearch.results.length > 0) {
            for (var i = 0; i < newsSearch.results.length; i++) {
                if (newsSearch.results[i].language == 'en') {

                var p = document.createElement('p');
                var a = document.createElement('a');
                var h = document.createElement('h3');
                a.href = newsSearch.results[i].unescapedUrl;
                a.innerHTML = 
                     + ' (' + newsSearch.results[i].publisher + ')';
                a.setAttribute('target', '_blank');
                p.innerHTML = newsSearch.results[i].content;

    function onLoad() {
        newsSearch = new;
        newsSearch.setSearchCompleteCallback(this, searchComplete, null);

    #anthologyGoogleNews h3
        padding: 4px 4px 4px 0;
        font-size: 1.2em;
        width: 828px;
        font-weight: bold;
        color: #336;
    #anthologyGoogleNews h3 a,
    #anthologyGoogleNews h3 a:link,
    #anthologyGoogleNews h3 a:visited,
    #anthologyGoogleNews h3 a:hover,
    #anthologyGoogleNews h3 a:active {
        color: #336;
        text-decoration: none;
<div id="anthologyGoogleBranding"></div>
<div id="anthologyGoogleNews">Please wait whilst we load the news</div>

About smattey

Sumit Mattey is the Leader, Cloud Technologist & Evangelist, Husband, Father and Fun Loving person. Currently working as - PROJECT MANAGER, R Systems Int'l Ltd.(Salesforce) Not simply defined by his career, Sumit lives with his family (whom he loves so much). He is an avid movie buff, a big book worm, a lover of food and beverage. While his schedule has not been forgiving as he'd like, he also enjoys doing photography with great outdoors and tries to hunt as often as possible.
This entry was posted in Integration,, Visualforce and tagged , , , , , , , , , . Bookmark the permalink.

6 Responses to Integration of Google News via Visualforce Page

  1. What’s up friends, its wonderful article about teachingand entirely explained, keep it
    up all the time.

  2. Daniel says:

    Hi Sumit, thanks for your description and for providing the code for Google News as visualforce. The code is working fine (results get shown as they should), but there is one flaw. Everytime I load an account page, I get a series of “pop-ups” (read error messages) that tells me message from weppage: “en”. I suppose this is connected to any of the google language settngs, but i have not yet figured out what it could be. Do you happen to know what might trigger this?
    Best regars,

    • smattey says:

      Hello Daniel,

      Sorry for the late response. I would say comment this line of code. (mentioned in next line)
      // alert(newsSearch.results[i].language);
      It was a java script alert which was creating the issues.

      Let me know in case you still face the issue.

      Sumit Mattey
      E –

  3. Hello! I’m at work browsing your blog from my new
    iphone! Just wanted to say I love reading your blog and look forward to all your posts!
    Carry on the outstanding work!

  4. davodavo says:

    Looks like Google deprecated this API, as I am not able to get any results back from it.
    Does anybody know of a version of this feature that uses their new API?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s