Facebook post with asp



有人能帮我设置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

好吧,代表用户发布状态更新的api url是带有POST http请求和授权令牌的https://graph.facebook.com/USERID/feed,所以你基本上必须进行至少三次调用(一次用GET方法获取,一次用auth令牌获取,一个用POST方法发布)。POST"动作"有一系列属性,如链接、消息、隐私、标题等。但不要忘记令牌,否则它不起作用。。。如果你自己测试它,它会更容易(因为你可以在图形资源管理器工具上获得令牌,而你的令牌永远不会过期)。看看它是否有效。

EDIT:这里有一个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);
            }
        }

//希望所有括号都已关闭。

?>

最新更新