2013-04-24 88 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。