We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28788
    • 79 Posts
    Hi guys,

    I’ve been looking at Ping.fm and thinking it could be a fantastic way of adding content to a Modx based site or blog. For those who don’t know it’s basically a service that posts various types of content to one or more social networking or blog sites. Modx isn’t in their list but they do have something they call a custom url.

    On their google groups page [link] they have an example php script which will email your content to you via Ping.fm and your own site, I imagine this could be adapted or rewritten as a snippit to post a new document to Modx? Unfortunately I wouldn’t know where to start, my php is nearly nil but if anyone could take a look it could be pretty useful for many. I imagine they might add Modx to their list of supported services too which could be good.

    Thanks all.
    Ping.fm
    Google group on custom URL
    • Are you hoping to post to MODx from Pingfm or to Pingfm from MODx? The latter is easy the former is tricky and filled with security issues.

      Let me know what you were thinking.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
        • 28788
        • 79 Posts
        To Modx from Ping.fm micro-blogging style, as that is kind of the point of Ping.fm. Problematic?

        They have a ton of supported blogging platforms already such as Wordpress, Blogger and Tumblr etc so I guessed it would be doable.
          • 10449
          • 956 Posts
          I think it would be quite easy to do. But you def. need to watch out for security issues. How safe can a "secret" URL be?

          Another related method you might find interesting, is posting to your site/blog via email: http://sottwell.com/email-posting.html
            • 28788
            • 79 Posts
            Thanks actually that email posting link is really cool and might solve the issue via one route.

            Otherwise I can see where the security issue could be a problem, currently they are just suggesting a secret URL but I’ve just found this in the Google group from the developer:

            There will be facilities for authenticated custom URL posts in the near future.

            Since in theory there will be the facility for authentication would anyone be willing to help me get this working as is (just using a secret URL)? I’ll look into the authentication stuff as it comes.

            Thanks for you help so far.
              • 10449
              • 956 Posts
              Well, you already have the building blocks you need.

              It’s basically just:

              a) input validation / filtering (ping.fm tutorial / example script)
              b) enter data in modx (see the email-to-modx tutorial on page 2)

              For step b) there are alternative methods:

              - Doc Manager class: http://modxcms.com/forums/index.php/topic,5983.0.html
              - CakeMODx: http://modxcms.com/forums/index.php/topic,35663.0/topicseen.html
                • 28788
                • 79 Posts
                Ok, I’ll do my best and we’ll how it goes. Thanks for the links too.
                • It might not be bad to create a very limited manager user who can only create documents in a single parent document group and use that user explicitly for submitting posts as part of such a script. It doesn’t make sense to open up to being able to access the manager from a script. I have considered such actions for blog posts from a remote editor too. So a secret (random url) with restricted user access to only perform specific adds and even better to only permit such adds from a specific referrer (this can be spoofed). I would strongly recommend using the MODx api directly to login, create the document and log out.
                    Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
                    • 28788
                    • 79 Posts
                    smashingred that sounds sensible I’ll take a look at that next.

                    This is what I’m currently using which works well but is totally without security as mentioned (thanks agin for the links ganeshXL):
                    <?php
                    require_once('assets/libs/docapi/docmanager.class.inc.php');
                    $submited=isset($_POST['submit']);
                    
                    
                    if($_POST["title"] != ""){
                    	$body .= "Title: {$_POST["title"]}\n";
                    }
                    
                    $body .= "" .stripslashes($_POST["message"]) ."\n";
                    
                    if($_POST["location"] != ""){
                    	$body .= "Location: {$_POST["location"]}\n";
                    }
                    
                    if($_POST["media"] != ""){
                    	$body .= "\nExtra media variables:\n\n";
                    	$body .= "Raw Message: {$_POST["raw_message"]}\n";
                    	$body .= "Media URL: {$_POST["media"]}\n";
                    }
                     
                    if($_POST["trigger"] != ""){
                    	$body .= "Trigger: {$_POST["trigger"]}\n";
                    }
                    
                    if(!$submited) {
                    	$doc = new Document();
                    	$doc->Set('pagetitle','pagetitle');
                    	$doc->Set('parent',parentid);
                    	$doc->Set('alias','post-'.date("Y-m-d"));
                    	$doc->Set('content',$body);
                    	$doc->Set('tvtags','tags');
                    	$doc->Set('template','template');
                    	$doc->Set('hidemenu', 0);
                    	$doc->Save();
                    }
                    ?>
                    


                    Could anyone help me pull URLs out of the $body so they can actually display as URLs? That kind of filter is beyond my php abilities.
                      • 28788
                      • 79 Posts
                      Actually I may have it. Back soon.