Post to facebook wall with classic ASP

2019-06-06 16:52发布

I have a problem posting to facebook wall with classic asp. The variables fbName, fbUserID, accessToken are set in "real life" - i just deleted it here. I have the correct permissions for posting to a users wall ("publish_stream").

The post is not posted on the facebook wall of the user. Did I make any mistakes?

fbName = ""
fbUserID = ""
accessToken = ""

strURL = "https://graph.facebook.com/" & fbUserID & "/feed"
strMessage = fbName & " just did something."
strLink = "http://www.orf.at/"
strAccessToken = accessToken

para = "?access_token=" & strAccessToken & "&message=" & strMessage & "&link=" & strLink

set xmlDoc = createObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
bLoaded = xmlDoc.load(strURL & para)

i am sorry, i can't answer my own question. But here is the correct solution:

The correct answer is:

Dim xmlHttp 
Dim res

set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP") 


xmlHttp.Open "POST", strURL & para, false
xmlHttp.setRequestHeader "Content-type","application/x-www-form-urlencoded"
xmlHttp.send

To fetch some errors:

res = xmlHttp.responseText
Response.Write "res: " & res & "<br>"
Response.Write "Status: " & xmlHttp.Status & "<br>"

1条回答
劳资没心,怎么记你
2楼-- · 2019-06-06 17:23

It looks like you're not using a Http Post request. You need something like this(untested)

Dim xmlHttp
set xmlHttp = CreateObject("Microsoft.xmlHttp")


xmlHttp.Open "POST", strURL & para
xmlHttp.setRequestHeader "Content-type","application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Content-Length",len(sendData) 

xmlHttp.send 

Dim response
response = xmlHttp.responseText
查看更多
登录 后发表回答