1

Facebook API を使用し、ユーザーの友達リストにログインして、C# で Web サイトを開発しています。このリストを、チェックボックス、友達の写真、名前、およびユーザー ID を使用して Datalist にバインドします。

いくつかのチェックボックスをオンにしてボタンをクリックすると、チェックボックスをオンにした友人に何らかの招待状を送信したいと考えています。プライベート メッセージ、通知、またはその他のソリューション (ただし、ユーザーのウォールではありません) を介して招待状を送信したいと考えています。これは可能ですか?

既に Stackoverflow にあるすべての投稿を確認しました。また、これをチェックしましたhttp://www.fbrell.com/xfbml/fb:server-fbml-multi-friend-selector

4

2 に答える 2

1

あなたが探しているのは と呼ばれるもの"App-generated Requests"です。これらは、ユーザーがリクエスト ダイアログを表示したり操作したりする必要なく、アプリケーション内から送信されるリクエストです。

次のコードは、Facebook のドキュメントから抜粋したものです - https://developers.facebook.com/docs/channels/#requests

<?php 

  $app_id = YOUR_APP_ID;
  $app_secret = YOUR_APP_SECRET;

  $token_url = "https://graph.facebook.com/oauth/access_token?" .
    "client_id=" . $app_id .
    "&client_secret=" . $app_secret .
    "&grant_type=client_credentials";

  $app_access_token = file_get_contents($token_url);

  $user_id = THE_CURRENT_USER_ID;

  $apprequest_url ="https://graph.facebook.com/" .
    $user_id .
    "/apprequests?message='INSERT_UT8_STRING_MSG'" . 
    "&data='INSERT_STRING_DATA'&"  .   
    $app_access_token . "&method=post";

  $result = file_get_contents($apprequest_url);
  echo("App Request sent?", $result);
?>

送信されると、ユーザーが受信した新しいリクエストは、アプリケーションのブックマークにカウンターとして表示され、適切なダッシュボードの横にあるカウンターも増加します。

コードは PHP ですが、非常に一般的なfile_get_contents()方法を使用しています。このロジックは、HTTP 要求を作成できる任意の言語で使用できます。

于 2012-06-20T15:05:23.530 に答える
0

このコードは、あなたが投稿したいものは何でも、あなたの友人の壁に投稿します:

              for (Int32 i = 1; i < DLFbFriend.Items.Count; i++){

                CheckBox Chkbox =(CheckBox)DLFbFriend.Items[i].FindControl("chkUserID");
                if (Chkbox.Checked)
                {
                    HiddenField hdfUserId = (HiddenField)DLFbFriend.Items[i].FindControl("hdfUserID");
                    string d = hdfUserId.Value;//friend's facebook generated id,whom you want to invite
                    String link = "what ever you want to post";
                    string url1 = "https://graph.facebook.com/" + d + "/feed?access_token=" + Request.QueryString["access_token"] + "&link=" + link + "&from=" + Session["Pinny_USER"].ToString().Split('~')[0] + "&name=Register with Pinny&message=Your friend invites you&picture=http://168.144.124.15/images/logoPinny.jpeg";
                    HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url1);
                    request1.Method = "POST";
                    // execute the request
                    HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();

                    // we will read data via the response stream
                    System.IO.Stream ReceiveStream1 = response1.GetResponseStream();
                    StreamReader readStream1 = new StreamReader(ReceiveStream1);
                    string json1 = readStream1.ReadToEnd();
                    countinvited += 1;
                }
            }
于 2012-12-10T12:18:32.373 に答える