Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » onAfterWrite 500//There has been an error

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 949 Views
  • Bambii7
    Avatar
    Community Member
    254 Posts

    onAfterWrite 500//There has been an error Link to this post

    First off appologies for starting a new thread for this, I'm sure this has been covered.

    I'm using onAfterWrite to auto tweet blog posts as follows.

       function onAfterWrite() {
          parent::onAfterWrite();
          $this->Tweet();
       }
       
       function Tweet() {
          $twitterObj = new EpiTwitter(
             $TWITTER_CONSUMER_KEY="****",
             $TWITTER_CONSUMER_SECRET="****",
             $userToken="****",
             $userSecret="****"
          );
          $twitterObj->post(
             '/statuses/update.json',
             array(
                'status' => $this->Title.' '.Director::absoluteBaseURL().$this->Link()
             )
          );
       }

    The above code doesn't help much, altough it is working, it's just an error on saving which also doesn't help much. Does anyone know what would cause 500//There has been an error Failed to load source (found in the console of Fire Bug)

    For any one thats interested I'm using jmathai's Outh which can be downloaded here https://github.com/jmathai/twitter-async there is good documentation here http://www.jaisenmathai.com/articles/twitter-async-documentation.html#methodnames

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: onAfterWrite 500//There has been an error Link to this post

    The above code doesn't help much, altough it is working, it's just an error on saving which also doesn't help much. Does anyone know what would cause 500//There has been an error

    Put the site into devmode (or look at the error logs on your webserver) and you should get a much more useful error message. Could be a number of things.

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: onAfterWrite 500//There has been an error Link to this post

    cough cough, thanks again Willr, don't know why I didn't think of that.....

    line 245 EpiTwitter was throughing Exception, looks like the EpiTwitter is trying to post the tweet twice. This Oauth has been giving me a head ache so I lazily commented out the Exceptions, tweeting nicly and no save error, yea! thanks again

    949 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.