Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Write Once, Post Many? (WP, Facebook, Twitter, etc.)
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Write Once, Post Many? (WP, Facebook, Twitter, etc.)

raindog308raindog308 Administrator, Veteran

I'm looking for an app that will allow me to write a blog post, and then also post a notice that I've written a new blog post or an extract on Facebook, Twitter, etc.

I could write something myself to talk to those APIs but I'm sure someone has already done this...?

Blog is Wordpress, though I'm thinking of switch to Hugo.

Comments

  • WebGuruWebGuru Member
    edited July 2016

    Is it a self hosted wordpress? Try Social Media Auto Publish plugin

    https://wordpress.org/plugins/social-media-auto-publish/

    or you can try:

    NextScripts: Social Networks Auto-Poster

    https://wordpress.org/plugins/social-networks-auto-poster-facebook-twitter-g/

  • Maybe you could try IFTTT?

    Thanked by 3kkrajk Junkless Catalin
  • MacPacMacPac Member

    WordPress has a plugin that does that and it's jetpack

  • kkrajkkkrajk Member

    TheLonely said: Maybe you could try IFTTT?

    definitely worth the try

  • nfnnfn Veteran
  • HybridHybrid Member

    I wrote those for Yii2 modules, but should work for any PHP 5.5+ code

    Post to FB Page

    `use Yii;
    use Facebook\Facebook;

    class MFacebookHelper extends \yii\base\Object
    {
    public function postToFacebook($message, $url, $description, $image=null)
    {
    $params=array();
    $params["message"] = $message;

        if(!is_null($url))
        {
            $params["link"] = $url;
        }
    
        if(!is_null($image))
        {
            $params["picture"] = $image;
        }
        $params["description"] = $description;
    
        $fb = new Facebook([
          'app_id' => Yii::$app->params['fb_app_id'],
          'app_secret' => Yii::$app->params['fb_app_secret'],
          'default_graph_version' => Yii::$app->params['fb_default_graph_version'],
          'default_access_token' => Yii::$app->params['fb_default_access_token']
        ]);
        $page_id =  Yii::$app->params['fb_page_id'];
    
        try
        {
            //$response = $fb->post('/'.$page_id.'/feed', $params, $page_access_token);
            $response = $fb->post('/'.$page_id.'/feed', $params);
            return true;
        }
        catch(Facebook\Exceptions\FacebookResponseException $e)
        {
            //echo 'Graph returned an error: ' . $e->getMessage();
            return false;
        }
        catch(Facebook\Exceptions\FacebookSDKException $e)
        {
            //echo 'Facebook SDK returned an error: ' . $e->getMessage();
            return false;
        }
    }
    
    public function postImageToFacebook($message, $url, $description, $image=null)
    {
        $params=array();
    
        if(!is_null($image))
        {
            $fb = new Facebook([
              'app_id' => Yii::$app->params['fb_app_id'],
              'app_secret' => Yii::$app->params['fb_app_secret'],
              'default_graph_version' => Yii::$app->params['fb_default_graph_version'],
              'default_access_token' => Yii::$app->params['fb_default_access_token']
            ]);
            $page_id =  Yii::$app->params['fb_page_id'];
    
            $params["source"] = $fb->fileToUpload(Yii::$app->getUrlManager()->createAbsoluteUrl($image));
    
    
            try
            {
                // Returns a `Facebook\FacebookResponse` object
                $response = $fb->post('/me/photos', $params);
            }
            catch(Facebook\Exceptions\FacebookResponseException $e)
            {
                echo 'Graph returned an error: ' . $e->getMessage();
                exit;
            }
            catch(Facebook\Exceptions\FacebookSDKException $e)
            {
                echo 'Facebook SDK returned an error: ' . $e->getMessage();
                exit;
            }
        }
    }
    

    }`

    Post to Twitter

    `use Yii;
    use Abraham\TwitterOAuth\TwitterOAuth;

    class MTwitterHelper extends \yii\base\Object
    {
    public function postImageToTwitter($message, $url, $description, $image=null)
    {
    $params=array();

        if(!is_null($image))
        {
            $connection = new TwitterOAuth(Yii::$app->params['consumer_key'], Yii::$app->params['consumer_secret'], Yii::$app->params['access_token'], Yii::$app->params['access_token_secret']);
            $media1 = $connection->upload('media/upload', ['media' => Yii::$app->getUrlManager()->createAbsoluteUrl($image)]);
    
            $parameters = [
                'status' => Yii::$app->params['mainHashtag'] . ' ' . $message,
                'media_ids' => [$media1->media_id_string]
            ];
            $result = $connection->post('statuses/update', $parameters);
    
            //$params["source"] = $fb->fileToUpload(Yii::$app->getUrlManager()->createAbsoluteUrl($image));
    
        }
    }
    

    }
    `

  • doghouchdoghouch Member
    edited July 2016

    Redacted - not clear

  • HybridHybrid Member

    @doghouch said:
    Much copy and paste, such difficulty

    I wrote it. if you can find the same code on the web i'll give you a penny & a unicorn.

    Thanked by 1raindog308
  • I used IFTTT for over a year, and think is the best app do to a lot of things.

  • doghouchdoghouch Member
    edited July 2016

    @Hybrid said:

    @doghouch said:
    Much copy and paste, such difficulty

    I wrote it. if you can find the same code on the web i'll give you a penny & a unicorn.

    Wasn't talking about you :)

    EDIT: Removed it for the sake of clarity

    Thanked by 1Hybrid
  • NextScripts +1, I have the paid version. I think it is the all round best solution to this problem.

  • Did you try Shareaholic, I've been using it for a long time and it's really good. It's free and worth using.

Sign In or Register to comment.