SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Zealot naynay99's Avatar
    Join Date
    Jan 2010
    Location
    Los Angeles
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto post script to facebook

    Hi,

    I am making a backend for a client in php/mysql. I am almost done, now they want a couple of input fields for facebook and twitter so they can autopost to facebook and twitter. The backend allows them to post articles, images etc.. to the main site, when they do that, they now want(when they hit send) for that info to be submitted to facebook and twitter as well.

    I just started some research and see that facebook has a php sdk is that a good place to start? I just don't know where to begin with this and need some advice.

    Thanks!

  2. #2
    SitePoint Addict
    Join Date
    Sep 2004
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There you go, googled that for ya

    Twitter: send message from a PHP page using Twitter API
    5 Steps to publish on a facebook wall using php | TheUnical Technologies Blog

    Usually each of these well known companies expose APIs so that you can interact with their application from your application.

    Hope this helps

  3. #3
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both of those seem to be outdated.

    I too am interested in achieving this from a CMS though Facebook seems to have made it particularly hard to do.

  4. #4
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For Twitter I recently used this and it works.
    Code PHP:
    function postTwitter($twitter_message) {
      // Use Matt Harris' OAuth library to make the connection
      // This lives at: [url]https://github.com/themattharris/tmhOAuth[/url]
      require_once('social/twitter/tmhOAuth.php');
     
      // Authorisation values required for posting to your personal twitter account.  Replace * with your details but remain inside the ''
    	  	// user_token may be referred to as Access Token 
      		// user_secret may be referred to as Access Token Secret
      	$connection = new tmhOAuth(array(
        	'consumer_key' => '',
        	'consumer_secret' => '',
        	'user_token' => '',
        	'user_secret' => '',
      	)); 
     
      // Connect to Twitter and post message
      	$connection->request('POST', 
      	  $connection->url('1/statuses/update'), 
      	  array('status' => $twitter_message));
      //Return success or not
      	return $connection->response['code'];
    }

    This is the function you call, you pass it a variable that contains the message you want to post and it does so. The four items 'consumer key', 'consumer secret', 'user token' and 'user secret' are codes you need to get from twitter to let you post.

    You will also need this code from Matt Harris

    https://github.com/themattharris/tmhOAuth

    Which processes the work for you. This site tells you how to get the codes you need: Twitter API Tutorial: Hello Twitter OAuth with PHP

    I'm still struggling to find a facebook way of doing it though.

  5. #5
    SitePoint Zealot naynay99's Avatar
    Join Date
    Jan 2010
    Location
    Los Angeles
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you dark warrior, I will check that out! As far as facebook goes, I have found this, you may have already seen them...

    Facebook SDK: Auto Post to Facebook | PHP | Damn Semicolon;

    Automatically post to Facebook from PHP script | Tips4PHP

    Thanks acid...

  6. #6
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the FB link

    With that ThmOath.php, I had to change two lines of code to get it work as it complained about them not being set for some reason. If you experience that issue let me know and I'll point out what I changed.

  7. #7
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that link nay nay, got it working great, just need to figure out how to make it post as the group page and not my personal account.

  8. #8
    SitePoint Zealot naynay99's Avatar
    Join Date
    Jan 2010
    Location
    Los Angeles
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet! Good to hear. Which link? Damnsemicolon? I will be working on mine end of the week and will keep you posted! Thanks again.

  9. #9
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The second one, tips4php. Facebook is really hard, I had a lot of trouble getting the tokens I needed but I can now post to a business page as the business instead of myself. Will be a pain doing that for each person that needs it but at least I know its doable.

  10. #10
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Posting to wall as admin

    Quote Originally Posted by darkwarrior View Post
    The second one, tips4php. Facebook is really hard, I had a lot of trouble getting the tokens I needed but I can now post to a business page as the business instead of myself. Will be a pain doing that for each person that needs it but at least I know its doable.
    I read this entry you made, about a year ago. I, too, am trying to post on the wall of a business page that I administer AS THE ADMIN...not as myself. I've almost got it. I've granted the app manage_pages permissions, and can post to the page, but it's still AS MYSELF. Can you hlep me to determine what else I may have to do to post AS ADMIN? I keep reading about UID, and page-ID and things like that, but can't find examples. A little lost. Working in PHP. What resources did you use to help you suceed? Any hlep would be aqppreciated. Thanks. Rick

  11. #11
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rickh101 View Post
    I read this entry you made, about a year ago. I, too, am trying to post on the wall of a business page that I administer AS THE ADMIN...not as myself. I've almost got it. I've granted the app manage_pages permissions, and can post to the page, but it's still AS MYSELF. Can you hlep me to determine what else I may have to do to post AS ADMIN? I keep reading about UID, and page-ID and things like that, but can't find examples. A little lost. Working in PHP. What resources did you use to help you suceed? Any hlep would be aqppreciated. Thanks. Rick
    Facebook may have changed how it works since I followed this tutorial but follow this http://www.damnsemicolon.com/php/aut...h-facebook-sdk

    It might be a bit confusing to follow but theres a section on there called "Post as a fan page". You basically take all the tokens and things you have and generate a new token that represents the admin of your business page, and that is the token that lets you post as someone else.

  12. #12
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by darkwarrior View Post
    Facebook may have changed how it works since I followed this tutorial but follow this http://www.damnsemicolon.com/php/aut...h-facebook-sdk

    It might be a bit confusing to follow but theres a section on there called "Post as a fan page". You basically take all the tokens and things you have and generate a new token that represents the admin of your business page, and that is the token that lets you post as someone else.
    Yes. I thought that was the concept, but couldn't figure out how to list the page-specific tokens. YOU DID IT! Worked like a champ. Thanks Dark...or do they call you Mr. Warrior. Sincere thanks for the final piece of my 24 hour puzzle. R

  13. #13
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rickh101 View Post
    Yes. I thought that was the concept, but couldn't figure out how to list the page-specific tokens. YOU DID IT! Worked like a champ. Thanks Dark...or do they call you Mr. Warrior. Sincere thanks for the final piece of my 24 hour puzzle. R
    No problem, glad I could help. Something to note, anytime you change your FB password, all your tokens will become invalid and you'll have to do the process again for new tokens.

  14. #14
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good to know. Thanks again. Can I be opportunisitc and pick your brain again? I know this is on a sort of unrelated topic, but if you have any thoughts, great. Here 'tis: I'm admin'ing a page for a company that, for years, used a profile instead of a page. An FB no-no. So last week I ran the FB profile - to - page migration tool. It did OK. Converted friends to likes, etc. BUT....the original profile is gone. I sort of expected that, but then again I'm still getting emails for events that the original profile had joined and have no way to quit the groups. It's as if a ghsot of the old profile DOES still exist. I was able to do the auto-post we're discussing in this tread by assigning my own, personal profile as an admin for the page in question. That works, but I'd like to get the old (even if now friendless) profile back. Any thoughts? Ideas? Gracias.

  15. #15
    SitePoint Member
    Join Date
    May 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by darkwarrior View Post
    Facebook may have changed how it works since I followed this tutorial but follow this http://www.damnsemicolon.com/php/aut...h-facebook-sdk

    It might be a bit confusing to follow but theres a section on there called "Post as a fan page". You basically take all the tokens and things you have and generate a new token that represents the admin of your business page, and that is the token that lets you post as someone else.
    It seems as if http://www.damnsemicolon.com is down. :-(

    I too am having problems with autoposting since all the recent changes to FB. I had sucessfully been posting to a page as the page for some time, then about two months ago, it just quit working. I've tried everything trying to get it to work again, but it seems all the tutorials available are from before all the FB changes in the API. Could one of you please Outline the steps needed to get this working again, and possibly give some code examples.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •