我们的应用正在使用此代码(Is it possibile to pass parameters to the callback URL of a FB app which is accessed through a tab?),但是当没有传入app_data参数时会出现问题。以下是我们的意思的示例:
工作正常:(“测试”写得很好) https://www.facebook.com/phillypours/app_397493550309543?app_data=test
不起作用: https://www.facebook.com/phillypours/app_397493550309543
Base64 Encode& amp; JSON解码:
myArray = Split(Request("signed_request"), ".")
encoded_sig = myArray(0)
payload = myArray(1)
sig = base64_decode(Replace(encoded_sig, "-_", "+/"))
set data = JSON.parse(base64_decode(Replace(payload, "-_", "+/")))
Response.Write data.app_data
这是我们在没有传入参数时收到的错误:
Object doesn't support this property or method: 'data.app_data'
任何人对如何陷阱都有任何想法?我无法对“data.app_data”做任何事情,因为这是引发错误的原因。
任何帮助将不胜感激!!!
谢谢。
丹尼斯
答案 0 :(得分:0)
我为此找到了解决方法。想与他人分享可能会受益。谢谢,丹尼斯
<!--#INCLUDE VIRTUAL="/includes/fb_base64.asp"-->
<!--#INCLUDE VIRTUAL="/includes/fb_json_decode.asp"-->
Function parsePageSignedRequest()
If Request("signed_request") <> "" Then
myArray = Split(Request("signed_request"), ".")
payload = myArray(1)
payload_decoded = base64_decode(payload)
set data = JSON.parse(payload_decoded)
If instr(payload_decoded,"""app_data""") Then
AppData = data.app_data
End If
If instr(payload_decoded,"liked"":true,") Then
LikeStatus = True
End If
End If
End Function