2017-04-05 47 views
1
var msg = context.MakeMessage(); 


      msg.Attachments = new List<Attachment>(); 

      SigninCard card = new SigninCard() 
      { 
       Text= "link it", 

       Buttons = new List<CardAction> 
         { 
          new CardAction 
          { 

           Value = "account linking url https", 
           Type = "account_link", 
           Title = "Link" 

          }, 

         } 
      }; 

      msg.Attachments.Add(card.ToAttachment()); 


await context.PostAsync(msg); 

我正在嘗試使用SignInCard鏈接Facebook帳戶。出現 此錯誤:對於url類型的按鈕,網址不能爲空

{ 「錯誤」:{ 「消息」: 「(#100)的Web網址不能爲空爲URL類型 按鈕」, 「類型」: 「OAuthException」, 「代碼」: 100,「error_subcode」:2018041,「fbtrace_id」:「GclYUUuTL2D」}}

但在url字段中有一個字符串https url。

有什麼想法?

回答

1

我明白了這一點。

var msg = context.MakeMessage(); 


      dynamic messageData = new JObject(); 
      messageData.attachment = new JObject(); 
      messageData.attachment.type = "template"; 
      messageData.attachment.payload = new JObject(); 
      messageData.attachment.payload.template_type = "generic"; 


      messageData.attachment.payload.elements 
       = new JArray(
        new JObject(
         new JProperty("title", "title"), 
         new JProperty("subtitle", "Link your account"), 
         new JProperty("buttons", 
          new JArray(
           new JObject(
            new JProperty("type", "account_link"), 
            new JProperty("url", "yourUrl") 
           ) 
          ) 
         ) 
        ) 
       ); 


      msg.ChannelData = messageData; 


       await context.PostAsync(msg); 
+1

今天我遇到了同樣的問題。有點瘋狂,你必須使用頻道特定的數據來解決它,不是嗎? HeroCard應該是通道不可知的。是否存在GitHub問題,你知道嗎? – oflahero

+0

更新:我正在使用'Type = ActionTypes.MessageBack'。當我切換到'Type = ActionType.ImBack'時,它工作。我認爲類似的枚舉更改會適用於您 - 回覆已發佈。 – oflahero

0

您不必進入通道專用ChannelData。在您的SigninCard的按鈕初始化,而不是

Type = "account_link", 

使用

Type = ActionTypes.Signin, 

他的工作是我的Facebook Messenger的通道。