有人可以帮我设置Facebook API,使用asp classic发布在墙上的文字,图片和链接吗?
随机脚本很简单但我似乎无法设置API。阅读Facebook开发人员的几个文档,但它全部用于PHP。
这是我的剧本,如何将图片和文字发布到Facebook?
dim myFileSys, Folder, FileName, urlpath, num, rsfb, conn, textfb, intGEN
Set myFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set Folder = myFileSys.GetFolder(Server.MapPath("/ftpupload/imagens"))
sub gen_pass(max_num)
dim gen_array(62)
gen_array(0) = "0"
gen_array(1) = "1"
gen_array(2) = "2"
gen_array(3) = "3"
gen_array(4) = "4"
gen_array(5) = "5"
gen_array(6) = "6"
gen_array(7) = "7"
gen_array(8) = "8"
gen_array(9) = "9"
Randomize
do while len(output) < max_num
num = gen_array(Int((9 - 0 + 1) * Rnd + 0))
output = output + num
loop
gen_pass = output
intGEN = CInt("2")
End sub
sub radm
call gen_pass(max_num)
For each file in Folder.Files
if num="" then
num="0"
else
num=num+1
end if
if num=intGEN then
FileName = file.name
end if
next
end sub
do while filename=""
call radm
loop
urlpath = "/ftpupload/imagens/"&filename
response.write urlpath
set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={MYSQL ODBC 5.1 DRIVER};Server=localhost;Port=3306;Database=fbposter;Uid=root;Pwd=1234;"
conn.Open()
Set rsfb = conn.Execute("Select * From facetext ORDER BY RAND() LIMIT 0,1")
if rsfb.eof then
textfb=rsfb.text
end if
Set myFileSys = nothing
set folder = nothing
set FileName = nothing
set urlpath = nothing
set num = nothing
set rsfb = nothing
set textfb = nothing
set intGEN = nothing
conn.close
答案 0 :(得分:0)
代表用户发布状态更新的api url是https://graph.facebook.com/USERID/feed
POST
http请求和授权令牌,因此您必须至少进行三次调用(一次获取) ,使用GET
方法,使用身份验证令牌,一个用于获取用户信息,另一个用POST
方法发布。 POST
“动作”具有一系列属性,例如链接,消息,隐私,标题等等,但不要忘记令牌或它不起作用......
如果你自己测试它会变得更容易(因为你可以在Graph Explorer Tool上获得令牌,而你的令牌永不过期)。看看它是否有效。
编辑:这是php中的一个例子,由Facebook编辑,用于您的目的。
<?
require '../src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => ' ',
'secret' => ' ',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) { //if there's an user logged in
//build an array with some paramenters
$parameters = array(
'message' => "isn't it nice when things just work?",
'picture' => "",
'link' => "",
'name' => "",
'caption' => "",
'description' => "" //etc. If parameters are blank but at least one is there, it doesn't matter.
);
//add the access token to it or it doesn't work
$parameters['user_access_token'] = $_SESSION['user_access_token']; //you get this somwhere else before posting
//build a url to call the Graph API with POST HTTP request
try {
$updateyourstatus = $facebook->api("/$user/feed", 'post', $parameters));
} catch (FacebookApiException $e) {
d($e);
}
}
//希望所有括号都关闭。
?>