Post to facebook wall with classic ASP

本秂侑毒 提交于 2020-01-03 02:42:12

问题


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:


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


来源:https://stackoverflow.com/questions/8890751/post-to-facebook-wall-with-classic-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!