2013-04-24 57 views
2

这不是给我任何错误,但它不张贴到我的粉丝页墙。 会喜欢这个一些帮助!试图弄清楚我自己一直是过山车。perl - Facebook图表 - 张贴到Fanpage

当然用正确的标记进行了测试。

#!/usr/bin/perl 

use strict; 
use warnings; 
use open qw(:std :utf8); 
use LWP::Simple; 
use YAML::Tiny; 
use JSON; 
use URI; 
use utf8; 

my $access_token = 'blah'; 
my $profile_id = '200117706712975'; 

#Publish to a facebook page as admin 
graph_api('/' . $profile_id . '/feed',{ 
     access_token => $access_token, 
     message => 'this is a test!', 
     link => 'http://test.com', 
     method => 'post' 
}); 

exit 0; 

sub graph_api { 
    my $uri = new URI('https://graph.facebook.com/' . shift); 
    $uri->query_form(shift); 
    my $resp = get("$uri"); 
    return defined $resp ? decode_json($resp) : undef; 
} 
+0

您可以尝试访问https://developers.facebook.com/tools/explorer并将您的访问令牌(由上面的perl脚本使用)替换为访问令牌字段。然后选择一个POST请求,设置消息字段和POST到200117706712975 /提要。这可以证明你的令牌和API正确地工作,缩小可能的原因。 – 2013-04-26 12:27:05

回答

1

如果您转储响应对象 - $ resp - 使用Data :: Dumper类似,您将得到帖子不出现的原因。响应对象是JSON。