0

有人可以帮我设置 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
4

1 回答 1

0

代表用户发布状态更新的 api url 是https://graph.facebook.com/USERID/feed带有POSThttp 请求和授权令牌的,所以你基本上必须进行至少三个调用(一个获取,使用 GET方法,身份验证令牌,一个获取用户的信息,一个发布,有POST方法)。“POST动作”有一系列的属性,比如链接、消息、隐私、标题等等等等。但是不要忘记token或者它不起作用......如果你自己测试它就可以了更容易(因为您可以在Graph Explorer Tool上获取令牌,并且您的令牌永不过期)。看看它是否有效。

编辑:这是Facebook为您的目的编辑的php 示例。

<?
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);
            }

        }

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

?>
于 2013-09-02T17:59:44.627 回答