2012-03-30 23 views
4

他の方法で複数の受信者にメッセージを投稿できますか? 論理を統合しようとしましたが、ここではFacebook send dialog to multiple friends using a recipients arrays と記載されていますが、動作していません。 IDのリストの最初の受信者に情報を送信することができます。Facebook APIを使用して複数の受信者にメッセージを送信

ありがとうございました。

+0

この回答を参照してくださいには、ソリューションは、FacebookのユーザーIDを持つ配列http://stackoverflow.com/questions/6469748/facebook-send-dialog-to-multiple-friends-using-a-recipientsを使用しているようです-arrays –

答えて

1

Facebookはこれをやりたがりませんので、回避する必要があります。メッセージングシステムが組み込まれたアプリを開発できます。次に、複数の受信者に同時にというリクエストを送信します。ユーザーがリクエストをクリックすると、アプリはメッセージを取得して表示する必要があります。

5

Facebookのメッセージを複数の友達に送信するための回避策を見つけました。

すべてのFacebookユーザーは自動的に@ facebook.comのメールアドレスを取得しています。 アドレスはパブリックユーザー名またはパブリックユーザーIDと同じです。

この電子メールアドレスには通常の電子メールを送信できます。 メールは通常のメッセージのようにFacebookの受信トレイに表示されます。

接続しているユーザーのメールを送信者として使用することは重要です。そうでない場合は、送信されません。

友人の電子メールアドレスを取得してWebサービスを呼び出す例です。

<div id="fb-root"></div> 
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script> 
<script type="text/javascript"> 
    FB.init({ 
     appId: '#APP_ID#', 
     status: true, 
     cookie: true, 
     xfbml: true 
    }); 

    FB.getLoginStatus(function (response) { 
     if (response.status === 'connected') { 
      GetData(); 
     } else { 
      Login(); 
     } 
    }); 

    function Login() { 
     FB.login(function (response) { 
      if (response.authResponse) { 
       GetData(); 
      } 
     }, { scope: 'email' }); 
    } 

    function GetData() { 
     //Get user data 
     FB.api('/me', function (response) { 
      //Sender 
      var sender = response.email; 

      //Get friends 
      FB.api('/me/friends', function (response) { 

       //Recepients array 
       var recipients = []; 
       var length = response.data.length; 
       var counter = 0; 

       //Loop through friends 
       for (i = 0; i < length; i++) { 
        var id = response.data[i].id; 

        //Get friend data 
        FB.api('/' + id, function (response) { 
         var recipient = ""; 

         //User got a username, take username 
         if (response.username) { 
          recipient = response.username + '@facebook.com'; 
         } 
         //No username, take id 
         else { 
          recipient = response.id + '@facebook.com'; 
         } 

         //Add e-mail address to array 
         recipients.push(recipient); 

         counter++; 
         //last email -> send 
         if (counter == length) { 
          SendEmail(sender, recipients); 
         } 
        }); 
       } 
      }); 
     }); 
    } 

    function SendEmail(sender, recipients) { 
     //Call webservice to send e-mail e.g. 
     $.ajax({ type: 'POST', 
      contentType: 'application/json; charset=utf-8', 
      dataType: 'json', 
      url: '#WEBSERVICE#', 
      data: '{ sender:"' + sender + '", recipients: ["' + recipients.join('","') + '"] }', 
      success: function (response) { 
       //do something 
      } 
     }); 
    } 
</script> 
+0

@ facebook.comアドレスにメッセージを送信しようとしていますが、それらは常に "spam"フォルダに隠されています。何か案は? http://webapps.stackexchange.com/questions/44844/why-does-email-sent-to-my-facebook-com-address-always-end-up-in-facebook-messag –

+0

この機能には注意が必要ですもう仕事はなく、[email protected]に送られたメールは跳ね返ります。 –

関連する問題