#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0

    Perl Facebook::Graph - Post on Page Wall as Page, not User


    Using the Perl module, Facebook::Graph, I have created some basic perl code that can post to my own wall. I can share a photo on my own wall. I can also post a simple wall message to one of the pages for which I am an admin. However, when I try to post a photo to the page, it posts as me, not as the page.

    Here is the sample code that posts as me, to the Facebook page. I need it to post as the Page, not as me.

    # previously, I obtained my Page's accesstoken, and other credentials
    # including the Facebook Page ID

    my $fb = Facebook::Graph->new(
    app_id => $facebook_application_id,
    secret => $facebook_application_secret
    );

    $fb->access_token($facebook_accesstoken);

    my $rstring = $fb
    ->add_photo
    ->to($facebookPageID)
    ->set_message('Look at this really cool photo!')
    ->set_source('./raw_image_example.jpg')
    ->publish
    ->as_string;

    print "$rstring\n\n";
    I am trying to figure out how to create a post to the wall of a Facebook page, as if it is being posted BY the page, not by me.

    I am trying to do that with the CPAN module, Facebook::Graph

    I cannot, for the life of me, figure this out. Any help would be most welcomed!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    830
    Rep Power
    496
    This is cross posted on the Perl Guru forum.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    ... some technical help is helpful, rather than a pointer about other posts, me thinks ...
  6. #4
  7. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,254
    Rep Power
    1810
    Seems to be what is happening in Recipe 3 provided with the module:

    Facebook::Graph::Cookbook::Recipe3 - Impersonation
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    Recipe 3 does *NOT* work. It posts as the user "fan" of a page, NOT as the page, itself.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    In addition, I am trying to add_photo, not add_post. The recipes are not complete, either, in the there is the ->to that needs to be set in order to "target" the Page (as opposed to the user's own wall). I have done extensive testing, and the results are that I cannot yet post AS the Page to the Page wall. There has to be something I am missing.

    If someone has a pointer to code that uses some other Perl module or code snippet that accomplished this task, please share. I would be so very thankful!
  12. #7
  13. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,254
    Rep Power
    1810
    Sorry I can't help more. I'm not a Facebook user.

    If I was, and if I wanted to do this, I would probably simply use LWP::UserAgent to send information directly to the service.

    Publishing

    Most nodes in the Graph API have edges that can be published to (such as Photos or Posts). All Graph API publishing is done simply with an HTTP POST request to the relevant endpoint with parameters included. For example, if you wanted to publish a post on behalf of someone, you would make an HTTP POST request as below:

    Code:
    POST graph.facebook.com
      /{user-id}/feed?
        message={message}&
        access_token={access-token}
    Source: facebook.com: using graph api
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    830
    Rep Power
    496
    Originally Posted by perl4ever
    ... some technical help is helpful, rather than a pointer about other posts, me thinks ...
    It is considered good practice to inform people about cross posts on this type of forum when you do it, to avoid duplicate work of people trying to help you.

    For the rest, I am sorry, but I can't help you, I am not a user of Facebook, I am not even sure that I really understand your question.

  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    I was not aware of the practice to divulge the cross-posting. Duly noted. My apologies for the omission.

    I will look at the suggestion of simply using an HTTP Post action, as opposed to using a Module wrapping the Facebook Graph API. Or, maybe I should extend the module, or do something of my own module.

    Thanks for all the input...

IMN logo majestic logo threadwatch logo seochat tools logo