0

ユーザーをアプリに招待するアクションを公開しようとしています。関連オブジェクトが定義済みの「プロファイル」オブジェクトである「招待」カスタム アクションを定義しました。「ユーザーXがユーザーYを招待した」アクションを投稿できるように使用しようとしています。私は以前にカスタム アクションを行ったことがあるので、ドリルを知っています。

テスト ユーザーを使用して API 呼び出しを行うことができ、API から新しい発行済みアクション ID を取得しています。ただし、送信者または受信者のフィードまたはタイムラインでアクションが表示されません。

重要事項:

  • ユーザーはテスト ユーザー (両方) であり、アクションは送信されていませんが、同様のことを (異なるタイプのオブジェクトで) 実行すると、同じ条件でうまく機能しました。
  • オブジェクトの URL には、Facebook グラフの URL (https://graph.facebook.com/xxxx) を使用しています。APIはそれをうまく食べているようです。

私は何を間違っていますか?

PS。リクエスト ダイアログ以外の招待メカニズムを実装するより良い方法を考えられる場合は、提案をお待ちしています。明確にするために、私は「publish_stream」権限を持っていませんが、「publish_actions」は持っています。

余談ですが、受信者 (アクション オブジェクト) に通知する方法 (または通知するかどうか) はわかりません。

4

2 に答える 2

0

OG アクションをユーザーの友人のウォールに投稿することはできません。最初にアプリを承認し、それらのアクションを事前に公開することに同意する必要があります。さらに、招待を受けることがアクションの目的ではありません。また、Facebook のポリシーでは、2 人のユーザーが実際に一緒にアクションを実行しない限り (文字通り同じ場所で、またはアプリ内で仮想的に)、アクションで 2 人のユーザーをタグ付けすることも許可されていません。

于 2012-08-11T05:49:31.073 に答える
0
make a Folder named as : Controls

Then add this: InviteControl.aspx
simply write :
<span id="invitespan" runat="server"></span>

InviteControl.ascx.cs : 

public partial class Controls_InviteControl : System.Web.UI.UserControl
{
    /// <summary>
    /// Show border or not
    /// </summary>
    public bool ShowBorder { set { showBorder = value; } }

    /// <summary>
    /// Display email section
    /// </summary>
    public bool EmailInvite { set { emailInvite = value; } }

    /// <summary>
    /// Number of rows. Allowed values are from 3 to 10. Default value is 5.
    /// </summary>
    public int Rows { set { rows = value; } }

    /// <summary>
    /// Number of columns. Allowed values are from 2,3 and 15. Default value is 5.
    /// </summary>
    public int Colums { set { colums = value; } }

    /// <summary>
    /// Set comma separated string of friend ID which you don't want to be in invite list
    /// </summary>
    public string ExcludeFriends { set { excludeFriends = value; } }

    /// <summary>
    /// IList of friend IDs which you don't want to be in invite list
    /// </summary>
    public IList<long> ExcludeFriendsList
    {
        set
        {
            if (value != null)
            {
                int i = 0;
                StringBuilder s = new StringBuilder();
                foreach (long id in value)
                {
                    i++;
                    s.Append(id.ToString());
                    if (i < value.Count)
                    {
                        s.Append(",");
                    }
                }
                excludeFriends = s.ToString();
            }
        }
    }

    /// <summary>
    /// URL where application should be redirected, after an invitation is sent.
    /// Default is application Canvas URL taken from web.config file.
    /// </summary>
    public string ActionUrl { set { actionUrl = value; } }

    /// <summary>
    /// URL where user will be redirected after the invite request is accepted.
    /// If it's not set, ActionUrl is used.
    /// </summary>
    public string AcceptUrl { set { acceptUrl = value; } }

    /// <summary>
    /// Main description which will apear on invite request
    /// </summary>
    public string Content { set { content = value; } }

    /// <summary>
    /// Application name displayed on send button and invite request title.
    /// Default is name taken from web.config file
    /// </summary>
    public string AppName { set { appName = value; } }

    /// <summary>
    /// Title of confirmation button inside invite request. Default value is 'Accept'
    /// </summary>
    public string ConfirmButtonTitle { set { confirmButtonTitle = value; } }

    /// <summary>
    /// Main title of control
    /// </summary>
    public string MainTitle { set { mainTitle = value; } }

    /// <summary>
    /// Refresh display of the control
    /// </summary>
    public void Refresh()
    {
        if (mainTitle == null) throw new Exception("Invite Friends Error:  Main Title is not set.");        
        if (content == null) throw new Exception("Invite Friends Error:  Content is not set.");

        if (confirmButtonTitle == null) throw new Exception("Invite Friends Error:  Confirm Button Title is not set.");
        if (actionUrl == null) actionUrl = Core.AppConfig.AppCanvasUrl;

        if (acceptUrl == null) acceptUrl = actionUrl;
        if (appName == null) appName = Core.AppConfig.AppName;

        StringBuilder html = new StringBuilder();
        html.Append("<fb:serverfbml ");
        html.Append("width='" + width + "'>");
        html.Append("<script type='text/fbml'>");
        html.Append("<div style='" + cssStyle + "' class='" + cssClass + "'>");
        html.Append("<fb:fbml>");
        html.Append("<fb:request-form method=\"POST\" action=\"");
        html.Append(actionUrl);
        html.Append("\" content=\"");
        html.Append(content);
        html.Append("<fb:req-choice url='");
        html.Append(acceptUrl);
        html.Append("' label='");
        html.Append(confirmButtonTitle);
        html.Append("' />\" type=\"");
        html.Append(appName);
        html.Append("\" invite=\"true\">");
        html.Append("<fb:multi-friend-selector target=\"_top\" condensed=\"false\" exclude_ids=\"");
        html.Append(excludeFriends);
        html.Append("\"  actiontext=\"");
        html.Append(mainTitle);
        html.Append("\" showborder=\"");
        html.Append(showBorder);
        html.Append("\" rows=\"");
        html.Append(rows);
        if (colums < 5) // fixing bug in FBML (if columns == 5 it renders as it as 4)
        {
            html.Append("\" cols=\"");
            html.Append(colums);
        }
        html.Append("\" email_invite=\"");
        html.Append(emailInvite);
        html.Append("\" />");
        html.Append("</fb:request-form> ");
        html.Append("</fb:fbml>");
        html.Append("</div>");
        html.Append("</script>");
        html.Append("</fb:serverfbml>");

        invitespan.InnerHtml = html.ToString();
    }

    /// <summary>
    /// Page Load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Refresh();
        }
    }


    /// <summary>
    /// Private members
    /// </summary>
    private string excludeFriends = "";
    private string actionUrl = null;
    private string acceptUrl = null;
    private string content = null;
    private string confirmButtonTitle = "Accept";
    private string appName = null;
    private string mainTitle = null;
    private bool showBorder = true;
    private bool emailInvite = true;
    private int rows = 4;
    private int colums = 4;
    private string cssStyle = "";
    private string cssClass = "";
    private int width = 625;


    /// <summary>
    /// Obsolete members/methods
    /// </summary>
    [Obsolete("You shouldn't use this property anymore. Use AppName instead")]
    public string SendButtonTitle { set { appName = value; } }
}


Then add a page : InviteFriends.aspx

copy and paste this :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InviteFriends.aspx.cs" Inherits="InviteFriends"
    EnableViewState="false" %>

<%@ Register Src="~/Controls/InviteControl.ascx" TagName="Invite" TagPrefix="cc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>
        <%= Core.AppConfig.AppName %></title>

    <script type="text/javascript">
        window.fbAsyncInit = function() {
            FB.Canvas.setAutoGrow();
        }
    </script>

</head>
<body>
    <div id="page">
        <div>
            <asp:Literal runat="server" ID="lInitFB" />
            <form id="form1" runat="server">
            <div runat="server" id="dvCanvas">
                <div id="workfield">
                    <div id="invite">
                        <cc:Invite runat="server" ID="ccInvite" ActionUrl="http://cflluxury.allsocialassets.com/InviteFriends.aspx"
                            Content="Invite to Luxury app" ConfirmButtonTitle="Confirm" MainTitle="Luxury App" />
                    </div>
                </div>
            </div>
            </form>
        </div>
    </div>
    <div id="fb-root">
    </div>

    <script src="http://connect.facebook.net/en_US/all.js"></script>

    <script>
        FB.init({
            appId: '414171951949853',
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true // parse XFBML
        });
    </script>
</body>
</html>

Then give a link to that invite page from your default page: 

<a href="InviteFriends.aspx">Invite Friend</a>

Hope it will help.
于 2012-05-16T12:25:30.820 に答える