Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Post on FB (cron)

by ultranerds (Friar)
on Mar 13, 2014 at 15:28 UTC ( #1078188=perlquestion: print w/replies, xml ) Need Help??
ultranerds has asked for the wisdom of the Perl Monks concerning the following question:

I'm going up the wall trying top get this going!

I'm trying to write a script, which will run via cron - and make posts to my GROUP (not wall, and actual group I manage)

So far I've got:
use Facebook::Graph; use LWP::Simple; my $access_token = 'xxx'; my $fb = Facebook::Graph->new( app_id => 378913472248618, secret => 'xxxx', postback => "https://www.facebook.com/connect/login_success.h +tml" ); $fb->access_token( $access_token ); $fb->add_post ->set_message('I like beer.') ->publish;
That works - and posts to MY wall... but how the heck do I get it to post on a group? I've been going round and round in circles with this for the last 2 hours.. and its doing my head in :/

TIA

Andy

Replies are listed 'Best First'.
Re: Post on FB (cron)
by Anonymous Monk on Mar 13, 2014 at 16:13 UTC
    id An profile id like sarahbownds or an object id like 16665510298 for th +e Perl page. add_post ( [ id ] ) Creates a Facebook::Graph::Publish::Post object, which can be used to +publish data to a user's feed/wall.

    Sounds like you just need to pass the ID of the place you want to post to, into your add_post function

      The first listed method on the Facebook::Graph::Publish::Post should give this functionality.
      to ( id ) Specify a profile id to post to. Defaults to 'me', which is the currently logged in user.
      Then your code would be:
      my $groupid = 12345; $fb->add_post ->id($groupid) ->set_message('I like beer.') ->publish;
        BTW, this kinda works:
        $fb->access_token( $access_token ); $fb->add_post() ->to(490559244324622) ->set_message('I like beer.') ->publish;
        However, it seems to post on my wall, as my personal account (not the admin of the wall).
        Thanks for the reply. Thats what I assumed before, but to no avail - it just gives an error:

        Can't locate object method "id" via package "Facebook::Graph::Publish::Post" at test.cgi line 53.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1078188]
Front-paged by Arunbear
help
Chatterbox?
[Corion]: marto: Heh - I think that's a nice contractual trap, "you will not use other gods/engines besides ours" ;)
[Corion]: But if the base intention was to have CIG as "co-developers" who (have to) contribute changes back to the mainline, it makes sense to have them use no other engine
[marto]: yes, I hear that development house has been on its last legs for a couple of years now
[Corion]: Is anybody aware of what makes Android Oreo better than Android Nougat? I'm not sure if the architectural changes (etc) are there already that make upgrading an Oreo-kernel phone to a newer Android userland (Lineage OS) version feasible
[Corion]: Yeah, CryTek got blindsided (or whatever) by Unity and Unreal Engine being zero cost, and the CryTek documentation being bad/nonexistent I think
[Corion]: "zero monetary cost", because of course, it's gratis only if your time has no value :)
[marto]: I used to keep up to date with my android ROMs, updating to the nightly every other day
[marto]: in my experience the jump in major releases has been painless, and performed better

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-14 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?