SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
勉強会force   #4

Chatter Integration
       ISV Architect 中嶋 一樹
Chatterによって変わること




before            after
A社からオーダーが入っています。
B社に訪問してきました。田中CIOが部長の知り合いだそうです。
              田中CIO
   今日、C社にテレアポしました。1Mを超える案件に膨らむ可能性があります。
                    Force
            追加情報。Forceの引き合いもあるそうです。
          D社の案件、受注しました。600kです。
                   受注

             Summer’12がリリースされました。
                           Partner Summitの締め切りが間近です。
        HerokuにPHPサポートが追加されました。
       Heroku php fogとの違いは何ですか?
                                          100万人の集客
                         今年のCloudforceは100万人の集約を見込んでいます。
 Service Cloudに新機能が追加されました。
       Chatter Messenger機能が有効化されていますね。
     Radian6の新しい資料をアップしました。
                新しい資料       Homepageをリニューアルしました。




                Curation
What is Curation?


キュレーションとは、無数の情報の海の中から、自分の価値観
や世界観に基づいて情報を拾い上げ、そこに新たな意味を与え、
そして多くの人と共有すること。

            ∼佐々木俊尚 氏の「キュレーションの時代」より引用∼
demo
Architecture

                         キーフレーズを抽出
                     ③

                 ②        ④
Chatterフィードを取得


                          ダッシュボード生成




   アクセス

          ①
Source Code
// メンバーとなっているグループ一覧を取得
public function get_my_chatter_groups(){
  $url = $this->instance_url . "/services/data/" . $this->api_version . "/chatter/users/me/groups";
  $this->logger->logger("URL : " . $url, __CLASS__, __FUNCTION__);
  $response = $this->callout_for_get($this->access_token, $url);
  if ($this->logger->error){
      $this->logger->set_error("Failed to get my chatter groups.", __CLASS__, __FUNCTION__);
      return(false);
  }
  return($response['groups']);
}

// News Feedからフィード情報を取得
public function get_all_feeds(){
  $url = $this->instance_url . "/services/data/" . $this->api_version . "/chatter/feeds/news/me/feed-items";
  $this->logger->logger("URL : " . $url, __CLASS__, __FUNCTION__);
  $response = $this->callout_for_get($this->access_token, $url);
  if ($this->logger->error){
      $this->logger->set_error("Failed to get all feeds by group.", __CLASS__, __FUNCTION__);
      return(false);
  }
  return($response['items']);
}
Source Code
// Yahoo APIにフィード情報を送信し、キーフレーズを抽出
public function get_keywords($sentence, $min_score){
  $api_key = urlencode($this->api_key);
  $sentence = $this->strip_mention($sentence);
  $sentence = urlencode($sentence);
  $url = "http://jlp.yahooapis.jp/KeyphraseService/V1/extract?output=json&appid=" . $api_key;
  $response = $this->callout_for_post($url, $sentence);

    $offset = 0;
    $keywords = array();
    foreach($response as $k => $v){
       if ($v < $min_score){
           continue;
       }
       $keywords[$offset]['value'] = $k;
       $keywords[$offset]['score'] = $v;
       $offset++;
    }
    return($keywords);
}
海外とのコミュニケーション




before       after
demo
Architecture

               翻訳依頼 (非同期)        翻訳取得 (同期)
                             ③
               ②

                             ④
               Chatterに翻訳を書き込み




Chatterに書き込み
               ①
Source Code
// Chatterフィードに「=>言語記号」をともなう書き込みがあれば翻訳のためのメソッド(chatter_translate.request_translate)を実行
trigger feedItem_to_translate on FeedItem (after insert) {
    for (feedItem fi : Trigger.new) {
        string output_lang = '';
        if (fi.body.contains('=>en')){
            output_lang += 'en,';
        }
        if (fi.body.contains('=>ja')){
            output_lang += 'ja,';
        }
        if (fi.body.contains('=>es')){
            output_lang += 'es,';
        }
        if (fi.body.contains('=>fr')){
            output_lang += 'fr,';
        }
        if (fi.body.contains('=>it')){
            output_lang += 'it,';
        }
        if (fi.body.contains('=>zh-CN')){
            output_lang += 'zh-CN,';
        }
        if (output_lang != ''){
            string instanceUrl = URL.getSalesforceBaseUrl().toExternalForm();
            string sid = UserInfo.getSessionId();
            string fi_json = System.JSON.serialize(fi);
            chatter_translate.request_translate(sid, instanceUrl, 'feedItem', 'append', fi_json, output_lang);
        }
    }
}
Source Code
// 非同期で中間サーバへ翻訳リクエストを送信
public with sharing class chatter_translate {
    @future(callout=true)
    public static void request_translate(string sid, string instanceUrl, string object_type, string
translation_mode, string object_json, string output_lang){
        Http http_protocol = new Http();
        HttpRequest http_request = new HttpRequest();

        // Set the endpoint URL.
        instanceUrl = EncodingUtil.urlEncode(instanceUrl, 'UTF-8');
        sid = EncodingUtil.urlEncode(sid, 'UTF-8');
        output_lang = EncodingUtil.urlEncode(output_lang, 'UTF-8');
        String endpoint = 'https://chatter-translate.herokuapp.com/chatter/api.php?service=translate&sid='
+ sid + '&instanceUrl=' + instanceUrl + '&object_type=' + object_type + '&translation_mode=' +
translation_mode + '&output_lang=' + output_lang;
        http_request.setEndPoint(endpoint);

       // Set the HTTP verb to GET.
       http_request.setMethod('POST');

       // Set body
       http_request.setBody(object_json);

       // set callout timeout to 60sec(max)
       http_request.setTimeout(60000);

       // Send the HTTP request and get the response.
       // The response is in JSON format.
       if (!Test.isRunningTest()){
    		    http_protocol.send(http_request);
       }
    }
}
Source Code
  // Google Translate APIにテキストを送信して翻訳
   public function translate($input_lang, $output_lang, $text){
     if (is_array($text)){
         $q = '';
         foreach ($text as $k => $v){
            $q = $q . '&q=' . urlencode($v);
         }
     } else {
         $q = '&q=' . urlencode($text);
     }
     if ($input_lang){
         $url = "https://www.googleapis.com/language/translate/v2?format=text&key=" . $this->api_key . $q . "&source=" .
$input_lang . "&target=" . $output_lang;
     } else {
         $url = "https://www.googleapis.com/language/translate/v2?format=text&key=" . $this->api_key . $q . "&target=" .
$output_lang;
     }
     $response = $this->callout($url);
     $array_translation = array();
     foreach ($response['data']['translations'] as $k => $v){
         array_push($array_translation, $v['translatedText']);
     }
     return($array_translation);
   }
Chatterで       く。世界中から答えを得る。


 質問:XXXXXXXX

     回答1
                      質問:XXXXXXXX
     回答2
                             回答1

                             回答2

                             回答3

                             回答4

                             回答5

                             回答6




  before                 after
demo
Architecture
                                 翻訳取得 (同期)
             質問送信 (非同期)
                             ③
             ②                       ④
                             ⑤
             Chatterに類似質問を
             書き込み                類似質問取得 (同期)




Chatterに質問
              ①
Source Code

// Chatterフィードに「=>stackoverflow」をともなう書き込みがあれば、類似QA取得のためのメ
ソッド(chatter_stackoverflow.request_similarを実行)


trigger feedItem_to_stackoverflow on FeedItem (after insert) {
    for (feedItem fi : Trigger.new) {
        if (fi.body.contains('=>stackoverflow')){
            string instanceUrl = URL.getSalesforceBaseUrl().toExternalForm();
            string sid = UserInfo.getSessionId();
            string fi_json = System.JSON.serialize(fi);
            chatter_stackoverflow.request_similar(sid, instanceUrl, fi_json);
        }
    }
}
Source Code
// 非同期で中間サーバへ類似QA取得リクエストを送信
public with sharing class chatter_stackoverflow {
    @future(callout=true)
    public static void request_similar(string sid, string instanceUrl, string object_json){
        Http http_protocol = new Http();
        HttpRequest http_request = new HttpRequest();

        // Set the endpoint URL.
        instanceUrl = EncodingUtil.urlEncode(instanceUrl, 'UTF-8');
        sid = EncodingUtil.urlEncode(sid, 'UTF-8');
        String endpoint = 'https://chatter-translate.herokuapp.com/chatter/api.php?service=stackoverflow&sid='
+ sid + '&instanceUrl=' + instanceUrl;
        http_request.setEndPoint(endpoint);

        // Set the HTTP verb to GET.
        http_request.setMethod('POST');

        // Set body
        http_request.setBody(object_json);

        // set callout timeout to 60sec(max)
        http_request.setTimeout(60000);

        //   Send the HTTP request and get the response.
        //   The response is in JSON format.
        if   (!Test.isRunningTest()){
        	    http_protocol.send(http_request);
        }
    }
}
Source Code


  // StackExchange APIに英語翻訳された質問文を送信して類似QAを取得
  public function request_similar($title){
      $title = urlencode($title);
      $filter = urlencode('!BF)_06.x0cLAwTSeXymC1qQAk-hwP.');
      $url = "http://api.stackexchange.com/2.0/similar?order=desc&sort=relevance&title=" . $title .
"&site=stackoverflow&filter=" . $filter;
      $response = $this->callout($url);
      return($response['items']);
  }
Chatter連携のパターン




        Feed型       Curation型




                                fb
    Q
         &
                A



        応答型          変換型
Object Model



       FeedItem          FeedComment      FeedTrackedChange     FeedLike




NewsFeed          UserProfileFeed       CollaborationGroupFeed        RecordFeed
Chatter REST API vs. Apex
例えばCollaborationGroupFeedまたはRecordFeedに投稿する場合:


   Chatter REST API:
   POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/record/グルー
   プIDまたはレコードID/feed-items


  {
      "body" : {
          "messageSegments" : [
              {
                  "type": "Text",
                  "text" : "テスト書き込み”
                }
           ]
      }
  }



   Apex:
   feedItem fi = new feedItem(body='テスト書き込み', parentId='グループIDまたはレコードID');
   insert fi;
Chatter REST API vs. Apex
例えばUserProfileFeedに投稿する場合:


   Chatter REST API:
   POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/user-
   profile/ユーザーID/feed-items


  {
      "body" : {
          "messageSegments" : [
              {
                  "type": "Text",
                  "text" : "テスト書き込み”
                }
          ]
      }
  }



  Apex:
   feedItem fi = new feedItem(body='テスト書き込み', parentId='ユーザーID');
   insert fi;
Chatter REST API vs. Apex
例えばFeedCommentに投稿する場合:


  Chatter REST API:
  POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feed-items/親Feed
  のID/comments


  {
      "body" : {
          "messageSegments" : [
              {
                  "type": "Text",
                  "text" : "テスト書き込み”
               }
          ]
      }
  }



  Apex:
  feedComment fc = new feedComment(commentBody='テスト書き込み', parentId='親FeedのID');
  insert fc;
Chatter REST API vs. Apex
例えばNewsFeedを取得する場合:


  Chatter REST API:
  POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/news/me/feed-items




  Apex:
  List<NewsFeed> newsFeedList = [select id, parentId, body from newsfeed];
Follow.
       @nkjm
http://nkjmkzk.net

Más contenido relacionado

La actualidad más candente

PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門kwatch
 
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~Akabane Hiroyuki
 
Webシステム脆弱性LT資料
Webシステム脆弱性LT資料Webシステム脆弱性LT資料
Webシステム脆弱性LT資料Tomohito Adachi
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方kwatch
 
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」fukuoka.ex
 
BPStudy32 CouchDB 再入門
BPStudy32 CouchDB 再入門BPStudy32 CouchDB 再入門
BPStudy32 CouchDB 再入門Yohei Sasaki
 
PHPの今とこれから2021
PHPの今とこれから2021PHPの今とこれから2021
PHPの今とこれから2021Rui Hirokawa
 
Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Hiroshi Tokumaru
 
Php5 4勉強会
Php5 4勉強会Php5 4勉強会
Php5 4勉強会Yuji Otani
 
PHPの今とこれから2014
PHPの今とこれから2014PHPの今とこれから2014
PHPの今とこれから2014Rui Hirokawa
 
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみました
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみましたEucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみました
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみましたEtsuji Nakai
 
Good Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX PhilosophyGood Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX PhilosophyYuya Takeyama
 
最新PHP事情 (2000年7月22日,PHPカンファレンス)
最新PHP事情 (2000年7月22日,PHPカンファレンス)最新PHP事情 (2000年7月22日,PHPカンファレンス)
最新PHP事情 (2000年7月22日,PHPカンファレンス)Rui Hirokawa
 
XPagesで検索してみよう
XPagesで検索してみようXPagesで検索してみよう
XPagesで検索してみようMasahiko Miyo
 
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版あります
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版ありますElixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版あります
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版ありますfukuoka.ex
 
PHPの今とこれから 2013
PHPの今とこれから 2013PHPの今とこれから 2013
PHPの今とこれから 2013Rui Hirokawa
 

La actualidad más candente (20)

PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
 
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~
ビギナーだから使いたいO/Rマッパー ~Tengを使った開発~
 
Webシステム脆弱性LT資料
Webシステム脆弱性LT資料Webシステム脆弱性LT資料
Webシステム脆弱性LT資料
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
 
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」
【LT版】Elixir入門「第7回:Python/KerasをElixirから繋いでアレコレする」
 
Jjug2009 Fall
Jjug2009 FallJjug2009 Fall
Jjug2009 Fall
 
BPStudy32 CouchDB 再入門
BPStudy32 CouchDB 再入門BPStudy32 CouchDB 再入門
BPStudy32 CouchDB 再入門
 
PHPの今とこれから2021
PHPの今とこれから2021PHPの今とこれから2021
PHPの今とこれから2021
 
Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介
 
Php5 4勉強会
Php5 4勉強会Php5 4勉強会
Php5 4勉強会
 
PHPの今とこれから2014
PHPの今とこれから2014PHPの今とこれから2014
PHPの今とこれから2014
 
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみました
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみましたEucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみました
EucalyptusのHadoopクラスタとJaqlでBasket解析をしてHiveとの違いを味わってみました
 
Good Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX PhilosophyGood Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX Philosophy
 
最新PHP事情 (2000年7月22日,PHPカンファレンス)
最新PHP事情 (2000年7月22日,PHPカンファレンス)最新PHP事情 (2000年7月22日,PHPカンファレンス)
最新PHP事情 (2000年7月22日,PHPカンファレンス)
 
HHVM Hack
HHVM HackHHVM Hack
HHVM Hack
 
あらためてPHP5.3
あらためてPHP5.3あらためてPHP5.3
あらためてPHP5.3
 
XPagesで検索してみよう
XPagesで検索してみようXPagesで検索してみよう
XPagesで検索してみよう
 
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版あります
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版ありますElixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版あります
Elixir入門「第1回:パターンマッチ&パイプでJSONパースアプリをサクっと書いてみる」【旧版】※新版あります
 
Django boodoo
Django boodooDjango boodoo
Django boodoo
 
PHPの今とこれから 2013
PHPの今とこれから 2013PHPの今とこれから 2013
PHPの今とこれから 2013
 

Destacado

Wireless Substitution: State-level Estimates From the National Health Intervi...
Wireless Substitution: State-level Estimates From the National Health Intervi...Wireless Substitution: State-level Estimates From the National Health Intervi...
Wireless Substitution: State-level Estimates From the National Health Intervi...Path of the Blue Eye Project
 
活躍中のアプリケーションから紐解くForcecom
活躍中のアプリケーションから紐解くForcecom活躍中のアプリケーションから紐解くForcecom
活躍中のアプリケーションから紐解くForcecomKazuki Nakajima
 
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...Dr.-Ing. Thomas Hartmann
 
Socialvoice for support intro
Socialvoice for support introSocialvoice for support intro
Socialvoice for support introKazuki Nakajima
 
Oracle Cloudのjava実行環境
Oracle Cloudのjava実行環境Oracle Cloudのjava実行環境
Oracle Cloudのjava実行環境Kazuki Nakajima
 

Destacado (7)

Chatterを使ったカスタムソーシャル
Chatterを使ったカスタムソーシャルChatterを使ったカスタムソーシャル
Chatterを使ったカスタムソーシャル
 
Wireless Substitution: State-level Estimates From the National Health Intervi...
Wireless Substitution: State-level Estimates From the National Health Intervi...Wireless Substitution: State-level Estimates From the National Health Intervi...
Wireless Substitution: State-level Estimates From the National Health Intervi...
 
活躍中のアプリケーションから紐解くForcecom
活躍中のアプリケーションから紐解くForcecom活躍中のアプリケーションから紐解くForcecom
活躍中のアプリケーションから紐解くForcecom
 
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...
OCAS @ ISWC 2011 - Generic Multilevel Approach Designing Domain Ontologies Ba...
 
Socialvoice for support intro
Socialvoice for support introSocialvoice for support intro
Socialvoice for support intro
 
Oracle Cloudのjava実行環境
Oracle Cloudのjava実行環境Oracle Cloudのjava実行環境
Oracle Cloudのjava実行環境
 
Drawloop intro
Drawloop introDrawloop intro
Drawloop intro
 

Similar a 勉強会force#4 Chatter Integration

Data api workshop at Co-Edo
Data api workshop at Co-EdoData api workshop at Co-Edo
Data api workshop at Co-EdoYuji Takayama
 
初めての Data api cms どうでしょう - 大阪夏の陣
初めての Data api   cms どうでしょう - 大阪夏の陣初めての Data api   cms どうでしょう - 大阪夏の陣
初めての Data api cms どうでしょう - 大阪夏の陣Yuji Takayama
 
[東京] JapanSharePointGroup 勉強会 #2
[東京] JapanSharePointGroup 勉強会 #2[東京] JapanSharePointGroup 勉強会 #2
[東京] JapanSharePointGroup 勉強会 #2Atsuo Yamasaki
 
初めての Data API CMS どうでしょう - 仙台編 -
初めての Data API   CMS どうでしょう - 仙台編 -初めての Data API   CMS どうでしょう - 仙台編 -
初めての Data API CMS どうでしょう - 仙台編 -Yuji Takayama
 
Data apiで実現 進化するwebの世界
Data apiで実現 進化するwebの世界Data apiで実現 進化するwebの世界
Data apiで実現 進化するwebの世界Yuji Takayama
 
初めての Data api
初めての Data api初めての Data api
初めての Data apiYuji Takayama
 
Streaming API で実現する クラウド ⇔ イントラ連携
Streaming API で実現する クラウド ⇔ イントラ連携Streaming API で実現する クラウド ⇔ イントラ連携
Streaming API で実現する クラウド ⇔ イントラ連携Shinichi Tomita
 
OSSから学ぶSwift実践テクニック
OSSから学ぶSwift実践テクニックOSSから学ぶSwift実践テクニック
OSSから学ぶSwift実践テクニック庸介 高橋
 
ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用Yatabe Terumasa
 
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道20123時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012Yusuke Ando
 
文字コードの脆弱性はこの3年間でどの程度対策されたか?
文字コードの脆弱性はこの3年間でどの程度対策されたか?文字コードの脆弱性はこの3年間でどの程度対策されたか?
文字コードの脆弱性はこの3年間でどの程度対策されたか?Hiroshi Tokumaru
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについてtako pons
 
Twitter sphere of #twitter4j #twtr_hack
Twitter sphere of #twitter4j #twtr_hackTwitter sphere of #twitter4j #twtr_hack
Twitter sphere of #twitter4j #twtr_hackkimukou_26 Kimukou
 
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方Alfresco勉強会20120829: やさしいShareダッシュレットの作り方
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方linzhixing
 
モバイル開発@symfony
モバイル開発@symfonyモバイル開発@symfony
モバイル開発@symfonyDaichi Kamemoto
 
Couchbase MeetUP Tokyo - #11 Omoidenote
Couchbase MeetUP Tokyo - #11 OmoidenoteCouchbase MeetUP Tokyo - #11 Omoidenote
Couchbase MeetUP Tokyo - #11 Omoidenotekitsugi
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)Fujio Kojima
 

Similar a 勉強会force#4 Chatter Integration (20)

Data api workshop at Co-Edo
Data api workshop at Co-EdoData api workshop at Co-Edo
Data api workshop at Co-Edo
 
初めての Data api cms どうでしょう - 大阪夏の陣
初めての Data api   cms どうでしょう - 大阪夏の陣初めての Data api   cms どうでしょう - 大阪夏の陣
初めての Data api cms どうでしょう - 大阪夏の陣
 
[東京] JapanSharePointGroup 勉強会 #2
[東京] JapanSharePointGroup 勉強会 #2[東京] JapanSharePointGroup 勉強会 #2
[東京] JapanSharePointGroup 勉強会 #2
 
初めての Data API CMS どうでしょう - 仙台編 -
初めての Data API   CMS どうでしょう - 仙台編 -初めての Data API   CMS どうでしょう - 仙台編 -
初めての Data API CMS どうでしょう - 仙台編 -
 
Data apiで実現 進化するwebの世界
Data apiで実現 進化するwebの世界Data apiで実現 進化するwebの世界
Data apiで実現 進化するwebの世界
 
初めての Data api
初めての Data api初めての Data api
初めての Data api
 
Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7
 
Streaming API で実現する クラウド ⇔ イントラ連携
Streaming API で実現する クラウド ⇔ イントラ連携Streaming API で実現する クラウド ⇔ イントラ連携
Streaming API で実現する クラウド ⇔ イントラ連携
 
OSSから学ぶSwift実践テクニック
OSSから学ぶSwift実践テクニックOSSから学ぶSwift実践テクニック
OSSから学ぶSwift実践テクニック
 
ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用
 
Java EE8 Report
Java EE8 ReportJava EE8 Report
Java EE8 Report
 
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道20123時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012
3時間濃縮CakePHP2.1 in PHPカンファレンス北海道2012
 
test
testtest
test
 
文字コードの脆弱性はこの3年間でどの程度対策されたか?
文字コードの脆弱性はこの3年間でどの程度対策されたか?文字コードの脆弱性はこの3年間でどの程度対策されたか?
文字コードの脆弱性はこの3年間でどの程度対策されたか?
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについて
 
Twitter sphere of #twitter4j #twtr_hack
Twitter sphere of #twitter4j #twtr_hackTwitter sphere of #twitter4j #twtr_hack
Twitter sphere of #twitter4j #twtr_hack
 
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方Alfresco勉強会20120829: やさしいShareダッシュレットの作り方
Alfresco勉強会20120829: やさしいShareダッシュレットの作り方
 
モバイル開発@symfony
モバイル開発@symfonyモバイル開発@symfony
モバイル開発@symfony
 
Couchbase MeetUP Tokyo - #11 Omoidenote
Couchbase MeetUP Tokyo - #11 OmoidenoteCouchbase MeetUP Tokyo - #11 Omoidenote
Couchbase MeetUP Tokyo - #11 Omoidenote
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
 

Más de Kazuki Nakajima

ビーコンBotによるニュータイプな受付
ビーコンBotによるニュータイプな受付ビーコンBotによるニュータイプな受付
ビーコンBotによるニュータイプな受付Kazuki Nakajima
 
Apexで作成したrest apiをしっかり保護する方法
Apexで作成したrest apiをしっかり保護する方法Apexで作成したrest apiをしっかり保護する方法
Apexで作成したrest apiをしっかり保護する方法Kazuki Nakajima
 
Waterfall cafeで働くBot
Waterfall cafeで働くBotWaterfall cafeで働くBot
Waterfall cafeで働くBotKazuki Nakajima
 
AIが入った栄養士Botのアーキテクチャー
AIが入った栄養士BotのアーキテクチャーAIが入った栄養士Botのアーキテクチャー
AIが入った栄養士BotのアーキテクチャーKazuki Nakajima
 
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法Kazuki Nakajima
 
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分Kazuki Nakajima
 
無償のAPEXワークスペース取得方法
無償のAPEXワークスペース取得方法無償のAPEXワークスペース取得方法
無償のAPEXワークスペース取得方法Kazuki Nakajima
 
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?実はDatabase cloudだけで実現できる巷で噂の機械学習とは?
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?Kazuki Nakajima
 
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶKazuki Nakajima
 
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知るKazuki Nakajima
 
今さらきけない環境ハブ
今さらきけない環境ハブ今さらきけない環境ハブ
今さらきけない環境ハブKazuki Nakajima
 
Spring'15 ISV様向け新機能紹介
Spring'15 ISV様向け新機能紹介Spring'15 ISV様向け新機能紹介
Spring'15 ISV様向け新機能紹介Kazuki Nakajima
 
絶対使いたくなるAppexchangeアプリとそのアーキテクチャー
絶対使いたくなるAppexchangeアプリとそのアーキテクチャー絶対使いたくなるAppexchangeアプリとそのアーキテクチャー
絶対使いたくなるAppexchangeアプリとそのアーキテクチャーKazuki Nakajima
 
ビジネスアイデアを最速で形にできるApp exchange
ビジネスアイデアを最速で形にできるApp exchangeビジネスアイデアを最速で形にできるApp exchange
ビジネスアイデアを最速で形にできるApp exchangeKazuki Nakajima
 
キャンバス個人用アプリ 速習ガイド
キャンバス個人用アプリ 速習ガイドキャンバス個人用アプリ 速習ガイド
キャンバス個人用アプリ 速習ガイドKazuki Nakajima
 
Force.com canvas入門ガイド
Force.com canvas入門ガイドForce.com canvas入門ガイド
Force.com canvas入門ガイドKazuki Nakajima
 

Más de Kazuki Nakajima (20)

ビーコンBotによるニュータイプな受付
ビーコンBotによるニュータイプな受付ビーコンBotによるニュータイプな受付
ビーコンBotによるニュータイプな受付
 
Apexで作成したrest apiをしっかり保護する方法
Apexで作成したrest apiをしっかり保護する方法Apexで作成したrest apiをしっかり保護する方法
Apexで作成したrest apiをしっかり保護する方法
 
Waterfall cafeで働くBot
Waterfall cafeで働くBotWaterfall cafeで働くBot
Waterfall cafeで働くBot
 
AIが入った栄養士Botのアーキテクチャー
AIが入った栄養士BotのアーキテクチャーAIが入った栄養士Botのアーキテクチャー
AIが入った栄養士Botのアーキテクチャー
 
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法
AIを組み込んだ近未来のアプリケーションで感じる新しいサービスの新しい開発手法
 
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分
畑と会話するニュータイプなIo tアプリで加熱中の技術トレンドを鷲掴みにする45分
 
無償のAPEXワークスペース取得方法
無償のAPEXワークスペース取得方法無償のAPEXワークスペース取得方法
無償のAPEXワークスペース取得方法
 
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?実はDatabase cloudだけで実現できる巷で噂の機械学習とは?
実はDatabase cloudだけで実現できる巷で噂の機械学習とは?
 
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ
海外で人気沸騰中のIo tデバイスとdatabase cloudで構成するシンプルなiot構成を学ぶ
 
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る
鳥肌必至のニューラルネットワークによる近未来の画像認識技術を体験し、IoTの知られざるパワーを知る
 
今さらきけない環境ハブ
今さらきけない環境ハブ今さらきけない環境ハブ
今さらきけない環境ハブ
 
Spring'15 ISV様向け新機能紹介
Spring'15 ISV様向け新機能紹介Spring'15 ISV様向け新機能紹介
Spring'15 ISV様向け新機能紹介
 
絶対使いたくなるAppexchangeアプリとそのアーキテクチャー
絶対使いたくなるAppexchangeアプリとそのアーキテクチャー絶対使いたくなるAppexchangeアプリとそのアーキテクチャー
絶対使いたくなるAppexchangeアプリとそのアーキテクチャー
 
ビジネスアイデアを最速で形にできるApp exchange
ビジネスアイデアを最速で形にできるApp exchangeビジネスアイデアを最速で形にできるApp exchange
ビジネスアイデアを最速で形にできるApp exchange
 
キャンバス個人用アプリ 速習ガイド
キャンバス個人用アプリ 速習ガイドキャンバス個人用アプリ 速習ガイド
キャンバス個人用アプリ 速習ガイド
 
Upwardのご紹介
Upwardのご紹介Upwardのご紹介
Upwardのご紹介
 
Salesforce1入門
Salesforce1入門Salesforce1入門
Salesforce1入門
 
Force.com canvas入門ガイド
Force.com canvas入門ガイドForce.com canvas入門ガイド
Force.com canvas入門ガイド
 
Sugoisurvey intro
Sugoisurvey introSugoisurvey intro
Sugoisurvey intro
 
Rakumo intro
Rakumo introRakumo intro
Rakumo intro
 

Último

[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Danieldanielhu54
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 

Último (9)

[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 

勉強会force#4 Chatter Integration

  • 1. 勉強会force #4 Chatter Integration ISV Architect 中嶋 一樹
  • 3. A社からオーダーが入っています。 B社に訪問してきました。田中CIOが部長の知り合いだそうです。 田中CIO 今日、C社にテレアポしました。1Mを超える案件に膨らむ可能性があります。 Force 追加情報。Forceの引き合いもあるそうです。 D社の案件、受注しました。600kです。 受注 Summer’12がリリースされました。 Partner Summitの締め切りが間近です。 HerokuにPHPサポートが追加されました。 Heroku php fogとの違いは何ですか? 100万人の集客 今年のCloudforceは100万人の集約を見込んでいます。 Service Cloudに新機能が追加されました。 Chatter Messenger機能が有効化されていますね。 Radian6の新しい資料をアップしました。 新しい資料 Homepageをリニューアルしました。 Curation
  • 6. Architecture キーフレーズを抽出 ③ ② ④ Chatterフィードを取得 ダッシュボード生成 アクセス ①
  • 7. Source Code // メンバーとなっているグループ一覧を取得 public function get_my_chatter_groups(){ $url = $this->instance_url . "/services/data/" . $this->api_version . "/chatter/users/me/groups"; $this->logger->logger("URL : " . $url, __CLASS__, __FUNCTION__); $response = $this->callout_for_get($this->access_token, $url); if ($this->logger->error){ $this->logger->set_error("Failed to get my chatter groups.", __CLASS__, __FUNCTION__); return(false); } return($response['groups']); } // News Feedからフィード情報を取得 public function get_all_feeds(){ $url = $this->instance_url . "/services/data/" . $this->api_version . "/chatter/feeds/news/me/feed-items"; $this->logger->logger("URL : " . $url, __CLASS__, __FUNCTION__); $response = $this->callout_for_get($this->access_token, $url); if ($this->logger->error){ $this->logger->set_error("Failed to get all feeds by group.", __CLASS__, __FUNCTION__); return(false); } return($response['items']); }
  • 8. Source Code // Yahoo APIにフィード情報を送信し、キーフレーズを抽出 public function get_keywords($sentence, $min_score){ $api_key = urlencode($this->api_key); $sentence = $this->strip_mention($sentence); $sentence = urlencode($sentence); $url = "http://jlp.yahooapis.jp/KeyphraseService/V1/extract?output=json&appid=" . $api_key; $response = $this->callout_for_post($url, $sentence); $offset = 0; $keywords = array(); foreach($response as $k => $v){ if ($v < $min_score){ continue; } $keywords[$offset]['value'] = $k; $keywords[$offset]['score'] = $v; $offset++; } return($keywords); }
  • 10. demo
  • 11. Architecture 翻訳依頼 (非同期) 翻訳取得 (同期) ③ ② ④ Chatterに翻訳を書き込み Chatterに書き込み ①
  • 12. Source Code // Chatterフィードに「=>言語記号」をともなう書き込みがあれば翻訳のためのメソッド(chatter_translate.request_translate)を実行 trigger feedItem_to_translate on FeedItem (after insert) { for (feedItem fi : Trigger.new) { string output_lang = ''; if (fi.body.contains('=>en')){ output_lang += 'en,'; } if (fi.body.contains('=>ja')){ output_lang += 'ja,'; } if (fi.body.contains('=>es')){ output_lang += 'es,'; } if (fi.body.contains('=>fr')){ output_lang += 'fr,'; } if (fi.body.contains('=>it')){ output_lang += 'it,'; } if (fi.body.contains('=>zh-CN')){ output_lang += 'zh-CN,'; } if (output_lang != ''){ string instanceUrl = URL.getSalesforceBaseUrl().toExternalForm(); string sid = UserInfo.getSessionId(); string fi_json = System.JSON.serialize(fi); chatter_translate.request_translate(sid, instanceUrl, 'feedItem', 'append', fi_json, output_lang); } } }
  • 13. Source Code // 非同期で中間サーバへ翻訳リクエストを送信 public with sharing class chatter_translate { @future(callout=true) public static void request_translate(string sid, string instanceUrl, string object_type, string translation_mode, string object_json, string output_lang){ Http http_protocol = new Http(); HttpRequest http_request = new HttpRequest(); // Set the endpoint URL. instanceUrl = EncodingUtil.urlEncode(instanceUrl, 'UTF-8'); sid = EncodingUtil.urlEncode(sid, 'UTF-8'); output_lang = EncodingUtil.urlEncode(output_lang, 'UTF-8'); String endpoint = 'https://chatter-translate.herokuapp.com/chatter/api.php?service=translate&sid=' + sid + '&instanceUrl=' + instanceUrl + '&object_type=' + object_type + '&translation_mode=' + translation_mode + '&output_lang=' + output_lang; http_request.setEndPoint(endpoint); // Set the HTTP verb to GET. http_request.setMethod('POST'); // Set body http_request.setBody(object_json); // set callout timeout to 60sec(max) http_request.setTimeout(60000); // Send the HTTP request and get the response. // The response is in JSON format. if (!Test.isRunningTest()){ http_protocol.send(http_request); } } }
  • 14. Source Code // Google Translate APIにテキストを送信して翻訳 public function translate($input_lang, $output_lang, $text){ if (is_array($text)){ $q = ''; foreach ($text as $k => $v){ $q = $q . '&q=' . urlencode($v); } } else { $q = '&q=' . urlencode($text); } if ($input_lang){ $url = "https://www.googleapis.com/language/translate/v2?format=text&key=" . $this->api_key . $q . "&source=" . $input_lang . "&target=" . $output_lang; } else { $url = "https://www.googleapis.com/language/translate/v2?format=text&key=" . $this->api_key . $q . "&target=" . $output_lang; } $response = $this->callout($url); $array_translation = array(); foreach ($response['data']['translations'] as $k => $v){ array_push($array_translation, $v['translatedText']); } return($array_translation); }
  • 15. Chatterで く。世界中から答えを得る。 質問:XXXXXXXX 回答1 質問:XXXXXXXX 回答2 回答1 回答2 回答3 回答4 回答5 回答6 before after
  • 16. demo
  • 17. Architecture 翻訳取得 (同期) 質問送信 (非同期) ③ ② ④ ⑤ Chatterに類似質問を 書き込み 類似質問取得 (同期) Chatterに質問 ①
  • 18. Source Code // Chatterフィードに「=>stackoverflow」をともなう書き込みがあれば、類似QA取得のためのメ ソッド(chatter_stackoverflow.request_similarを実行) trigger feedItem_to_stackoverflow on FeedItem (after insert) { for (feedItem fi : Trigger.new) { if (fi.body.contains('=>stackoverflow')){ string instanceUrl = URL.getSalesforceBaseUrl().toExternalForm(); string sid = UserInfo.getSessionId(); string fi_json = System.JSON.serialize(fi); chatter_stackoverflow.request_similar(sid, instanceUrl, fi_json); } } }
  • 19. Source Code // 非同期で中間サーバへ類似QA取得リクエストを送信 public with sharing class chatter_stackoverflow { @future(callout=true) public static void request_similar(string sid, string instanceUrl, string object_json){ Http http_protocol = new Http(); HttpRequest http_request = new HttpRequest(); // Set the endpoint URL. instanceUrl = EncodingUtil.urlEncode(instanceUrl, 'UTF-8'); sid = EncodingUtil.urlEncode(sid, 'UTF-8'); String endpoint = 'https://chatter-translate.herokuapp.com/chatter/api.php?service=stackoverflow&sid=' + sid + '&instanceUrl=' + instanceUrl; http_request.setEndPoint(endpoint); // Set the HTTP verb to GET. http_request.setMethod('POST'); // Set body http_request.setBody(object_json); // set callout timeout to 60sec(max) http_request.setTimeout(60000); // Send the HTTP request and get the response. // The response is in JSON format. if (!Test.isRunningTest()){ http_protocol.send(http_request); } } }
  • 20. Source Code // StackExchange APIに英語翻訳された質問文を送信して類似QAを取得 public function request_similar($title){ $title = urlencode($title); $filter = urlencode('!BF)_06.x0cLAwTSeXymC1qQAk-hwP.'); $url = "http://api.stackexchange.com/2.0/similar?order=desc&sort=relevance&title=" . $title . "&site=stackoverflow&filter=" . $filter; $response = $this->callout($url); return($response['items']); }
  • 21. Chatter連携のパターン Feed型 Curation型 fb Q & A 応答型 変換型
  • 22. Object Model FeedItem FeedComment FeedTrackedChange FeedLike NewsFeed UserProfileFeed CollaborationGroupFeed RecordFeed
  • 23. Chatter REST API vs. Apex 例えばCollaborationGroupFeedまたはRecordFeedに投稿する場合: Chatter REST API: POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/record/グルー プIDまたはレコードID/feed-items { "body" : { "messageSegments" : [ { "type": "Text", "text" : "テスト書き込み” } ] } } Apex: feedItem fi = new feedItem(body='テスト書き込み', parentId='グループIDまたはレコードID'); insert fi;
  • 24. Chatter REST API vs. Apex 例えばUserProfileFeedに投稿する場合: Chatter REST API: POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/user- profile/ユーザーID/feed-items { "body" : { "messageSegments" : [ { "type": "Text", "text" : "テスト書き込み” } ] } } Apex: feedItem fi = new feedItem(body='テスト書き込み', parentId='ユーザーID'); insert fi;
  • 25. Chatter REST API vs. Apex 例えばFeedCommentに投稿する場合: Chatter REST API: POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feed-items/親Feed のID/comments { "body" : { "messageSegments" : [ { "type": "Text", "text" : "テスト書き込み” } ] } } Apex: feedComment fc = new feedComment(commentBody='テスト書き込み', parentId='親FeedのID'); insert fc;
  • 26. Chatter REST API vs. Apex 例えばNewsFeedを取得する場合: Chatter REST API: POST https://インスタンス.salesforce.com/services/data/v25.0/chatter/feeds/news/me/feed-items Apex: List<NewsFeed> newsFeedList = [select id, parentId, body from newsfeed];
  • 27. Follow. @nkjm http://nkjmkzk.net