Showing posts with label Integration. Show all posts
Showing posts with label Integration. Show all posts

Friday, June 10, 2011

Gmail Contextual Gadgets (Gmail - Twitter)

A Gmail contextual gadget is a gadget that is triggered by clues in Gmail, such as the contents of Subject lines and email messages. For example, Gmail already provides a YouTube contextual gadget. If the body of an email contains a link to a YouTube video, a clickable thumbnail view of the video appears at the bottom of the email.
A Gmail contextual gadget can be triggered by content in any of the following parts of an email:1. From
2. To
3. CC
4. Subject
5. Body
6. Sent/received timestamps

For more details please click here

I have created my first gmail contextual gadget which is fetching the details from Twitter account. I have currently triggered for the Subject of email.
For e.g. If I send an email with subject @devnatani (My twitter name) , it shows the twitter info related to that user at the bottom of the email.


This information can be helpful for end user to get the information about the user without logging into twitter account.


I am currently working with some other integrations with gmail contextual gadgets and I will update those on the blog. Many more to come related to gmail contextual gadgets...

Thanks,




Saturday, June 4, 2011

Salesforce LinkedIn Integration Using OAuth

OAuth (Open Authorization) is an open standard for authorization. It allows users to share their private resources (e.g. photos, videos, contact lists) stored on one site with another site without having to hand out their credentials, typically username and password.OAuth allows users to hand out tokens instead of credentials to their data hosted by a given service provider. Each token grants access to a specific site (e.g. a video editing site) for specific resources (e.g. just videos from a specific album) and for a defined duration (e.g. the next 2 hours). This allows a user to grant a third party site access to their information stored with another service provider, without sharing their access permissions or the full extent of their data.OAuth is a service that is complementary to, but distinct from, OpenID.

Authorization: I have implemented the LinkedIn integration using OAuth in salesforce. To authorize linkedIn, we need the Consumer key and Consumer secret. These can be fetched from here.

For more details please click here.

Authorization Screen:


I have created a visualforce page in salesforce and added this page as an inline visualforce page on contact detail page. In my current implementation I am generating a linkedIn request by "FirstName, LastName and Company(Custom Field)". We can add some more parameters in the request.

Below is the example of a sample request.

http://api.linkedin.com/v1/people-search?company-name=metacube&keywords=devendra%2Fnatani

I have used the Http class to send request to linkedIn Api. After successful authorization we get the response in following format.


  
    
      8QRmNSsquG
      Devendra
      Natani
    
  
  1


Then I fetch the id tag value and generate a another request to fetch the public profile url of this id. I have used that url in the vf page which I have used as a inline vf page on contact detail page layout.


Thanks,

Sunday, April 17, 2011

How to access Salesforce Content in .Net application using API

In today’s competitive marketplace,no one has time to wait months or years to implement a solution to help the sales team. That’s the beauty of the Salesforce model—because it’s on-demand, Salesforce Content takes a fraction of the implementation time that traditional software requires


I have created a application which can be used to open and save into salesforce content. I have used Enterprise.wsdl in .Net application. Below is the class which is used to login into salesforce account and have the methods related to salesforce content.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SalesforceContent.Enterprise;
using System.IO;

namespace SalesforceContent
{
    public class Content
    {
        public Content() { }
        public static string username { get; set; }
        public static string password { get; set; }
        public static SforceService binding {
            get
            {
                SforceService binding = new SforceService();
                binding = new SforceService();
                
                LoginResult lr = binding.login(username, password);
                binding.SessionHeaderValue = new SessionHeader();
                binding.SessionHeaderValue.sessionId = lr.sessionId;
                binding.Url = lr.serverUrl;
                binding.Url = lr.serverUrl;
                return binding;
            } 
        }

        public static sObject [] GetAvailableWorkspaces() {
                QueryResult query
                    = binding.query("select Id, Name from" 
                    + " ContentWorkspace");

                sObject[] records = query.records ;
                
                
                return records;
            }

        public static void SaveContent(String workspaceId,String path) {

        // Create a content version object
        ContentVersion contentVersion = new ContentVersion();

        // Set the mandatory field pathOnClient
        contentVersion.PathOnClient = path;
        
        FileStream fs = new FileStream(path, FileMode.Open,FileAccess.Read);

        // Create a byte array of file stream length
        byte[] data = new byte[fs.Length];

        //Read block of bytes from stream into the byte array
        fs.Read(data,0,System.Convert.ToInt32(fs.Length));

        //Close the File Stream
        fs.Close();

        // Set the binary file data
        contentVersion.VersionData = data;

        // We can set the title to something other than the
        // filename
        contentVersion.Title = "My Content File";

        // When publishing into a public workspace, the current
        // user must have publish permissions
        contentVersion.FirstPublishLocationId = workspaceId;

        // As we're publishing into a workspace we can set
        // additional meta-data
        contentVersion.TagCsv = "Test";
        
        
        // You can add multiple versions if required by adding
        // them to the array
        sObject[] array = new sObject[] { contentVersion };
        SaveResult[] saveResultArray = binding.create(array);
        foreach (SaveResult sr in saveResultArray) {
            if (sr.success) {
                String versionId = sr.id;
                // success created version in content.
                
            } else {
                //Failed to create entity
                foreach (Error error in sr.errors) {
                    // get error messages by error.getMessage()
                }
            }
        }
    }

        public static sObject[] OpenFromContent(String workspaceId)
        {
            QueryResult query
                = binding.query("select Id, Title, "
              + "ContentSize, FileType, VersionData, "
              + "PathOnClient from ContentVersion v where "
              + "v.FirstPublishLocationId = '" + workspaceId + "'");

            sObject[] records = query.records;
            return records;
        }
    }
}