Jump to content

From Processwire to Facebook


Manol
 Share

Recommended Posts

Hello guys.

     I would like some help on where to start to create a button that publishes from a processwire page ( title, text and image ) to the facebook wall.

     The idea is that the user writes some news in a processwire page and then  I will  use  the facebook api graph to publish on that user's wall.

    My idea was to develop a module to make it as reusable as possible ( and include google+ and tweeter ).

    I've got some ideas on how to do it, but maybe some of you have done something similar or face problems I haven't think about yet that could help.

Thank you.

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 5 weeks later...

Sorry, when you say:

but  results aren't triggering, I pasted the url directly into the browser but no changes at all.

do you mean that the rss feed itself is not updating, or that IFTTT is not sending the changes to FB?

Link to comment
Share on other sites

Hi Adrian.

    I used the enhanced rss module, created a template with this code:

  • $rss = $modules->get("MarkupRSSEnhanced");
  • $items = $pages->find("limit=10, sort=-modified"); // $items, PageArray of Pages
  • $rss = $modules->get("MarkupRSSEnhanced"); // load the module
  • $rss->render($items);

and when I call the a page creates with that template htt://mypage/rss I can see the xml, but IFTTT doesn't  detect the changes. I think I'm missing some very basic stuff.

Link to comment
Share on other sites

Hi Martijn

It says congratullations and also:

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

  • line 31, column 0: Missing atom:link with rel="self"

 

     <link>http://casergi.com/noticias/comida-de-empresa-para-navidad/</link>

    </item>
31 </channel>
    </rss>
 
I'm trying to understand the help file provided.
Link to comment
Share on other sites

Yes I changed to 1 minute but no results.

My original idea was to publish some stuff to facebook wall after saving a page in the admin area, title, description and images.

I got and external php that does exactly that and works:

<?php
 include_once 'inc/facebook.php';

 $appId = '703738********';
 $secret = 'd30530a5dcd*************';
 $returnurl = 'http://myweb.es/facebook/post.php';
 $permissions = 'manage_pages, publish_stream';
 
 $fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));
 
 $fbuser = $fb->getUser();
 
 if($fbuser){
		

        try{
            $message = array(
                'message' => 'foo'
            );

            $result = $fb->api('/me/feed/','POST',$message);
            if($result){
                echo 'Published';
            }
        }catch(FacebookApiException $e){
            echo $e->getMessage();
        }

    
 }else{
    $fbloginurl = $fb->getLoginUrl(array('redirect-uri'=>$returnurl, 'scope'=>$permissions));
    echo '<a href="'.$fbloginurl.'">Login with Facebook</a>';
 }
 
?>

I'm trying to implement that in a hook, there is a checkbox, if is on then publish to facebook

$this->pages->addHookAfter('save', $this, 'fb'); 

.....		

if($page->facebook==1) {

			 include_once 'fb/facebook.php';

			 $appId = '70373825******';
			 $secret = 'd30530a5dcd4e5829e6c8b********';
			 // $returnurl = 'http://indinet.es/facebook/post.php';
			 $returnurl = 'http://pwpage.com';
			 $permissions = 'manage_pages, publish_stream';
			 $fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));
			 
			 $fbuser = $fb->getUser();

			 $this->message("user " . $fbuser);
 
		} // facebook
....

I'm trying first to check the user id, but the result is just 0, whereas in the original file outside pw I get the user id without problems.

Any ideas, Why?

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...