[ABD] Twitter Auto Tweeter - 0.0.1

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
User avatar
phreakwars
Registered User
Posts: 239
Joined: Thu Feb 22, 2007 4:57 am
Location: Polaris Industries

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by phreakwars »

lrgrthnlf wrote:You could add it as an additional check to the if statement added to posting.php similar to the way I check for new vs. reply posts..
Could you explain please, I tried a couple different ways but I keep getting errors.

I am assuming you mean this bit of code

Code: Select all

if($config['enable_autopost']){    
       $username = $config['twitter_username'];
       $password = $config['twitter_password'];
       $message = $post_data['post_subject']." ". generate_board_url()."/viewtopic.php?t=$topic_id - ".$user->data['username'];
       $url = 'http://twitter.com/statuses/update.xml';
       $curl_handle = curl_init();
          curl_setopt($curl_handle, CURLOPT_URL, "$url");
          curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
          curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($curl_handle, CURLOPT_POST, 1);
          curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
          curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
          $buffer = curl_exec($curl_handle);
          curl_close($curl_handle);
      }
MODS by me: Default Topic Icon

lrgrthnlf
Registered User
Posts: 58
Joined: Fri Jun 14, 2002 7:29 am
Location: Melbourne, Australia

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by lrgrthnlf »

Yes... the if statement there..

$config['enable_autopost'] ... is the condition that the base mod imposes
$forum_id != 1 ... is the additional condition you wish to impose
$mode == 'post' ... is the condition I imposed in my variant..

&& means "AND" which in logic terms means that both the first and the second term must be true for the whole argument to be true as opposed to || which means "OR" (either may be true for the result to be true)..

This original if statement says that the code should only be run if the preference in the board settings is enabled.

Code: Select all

if($config['enable_autopost']){
...twitter posting code...
}
My variant says IF the twitter code is enabled AND it's a new post and not a reply or edit etc.

Code: Select all

if($config['enable_autopost'] && $mode == 'post'){
...
}
Therefore, if you want to add the condition "AND if the forum_id is NOT 1"

Code: Select all

if($config['enable_autopost'] && $forum_id != 1){
...
}
Want to tie it all together?

Code: Select all

if($config['enable_autopost'] && $mode == 'post' && $forum_id != 1){
...
}

User avatar
phreakwars
Registered User
Posts: 239
Joined: Thu Feb 22, 2007 4:57 am
Location: Polaris Industries

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by phreakwars »

Thanks, but I figured it out a bit ago.

What I did wrong was NOT save my new edit before I uploaded it and forgot a parentheses after the forum ID.

Silly me, I'm up too early and need to go back to bed. :lol:
.
.
MODS by me: Default Topic Icon

User avatar
phreakwars
Registered User
Posts: 239
Joined: Thu Feb 22, 2007 4:57 am
Location: Polaris Industries

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by phreakwars »

OK now I'm running into another problem. On twitter, The topic title is correct, but the URL is incorrect. It only lists the topic ID (which is also incorrect)

For example, it's showing the URL's as

Code: Select all

http://www.newsucks500.com/viewtopic.php?t=0
It should be somethng like

Code: Select all

http://www.newsucks500.com/viewtopic.php?t=topic_number_here
.
.
MODS by me: Default Topic Icon

User avatar
eqbeastlord
Registered User
Posts: 50
Joined: Thu Jan 02, 2003 2:45 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by eqbeastlord »

phreakwars wrote:OK now I'm running into another problem. On twitter, The topic title is correct, but the URL is incorrect. It only lists the topic ID (which is also incorrect)

For example, it's showing the URL's as

Code: Select all

http://www.newsucks500.com/viewtopic.php?t=0
It should be somethng like

Code: Select all

http://www.newsucks500.com/viewtopic.php?t=topic_number_here
.
.
Check replies --- this is what a few of us are getting at the moment. Initial posts have the 0 for topic #, but replies to that topic are working correctly.

User avatar
eqbeastlord
Registered User
Posts: 50
Joined: Thu Jan 02, 2003 2:45 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by eqbeastlord »

changing the

Code: Select all

?t=$topic_id
to

Code: Select all

?f=$forum_id&t=$topic_id
seems like it should work, but it always cuts off at the &. in &. Maybe it's my newbness, but why is that?

lrgrthnlf
Registered User
Posts: 58
Joined: Fri Jun 14, 2002 7:29 am
Location: Melbourne, Australia

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by lrgrthnlf »

EDIT: Fixed - only thing is it doesn't display author name now.. would probably need to shift to submit_post function to do that..

I suspect it's because the code is inserted into posting.php too early (the if block is too early in the code execution) so that it occurs before the new post has been inserted into the database and in doing so obtained its topic_id..

includes/functions_posting.php, included in posting.php, has a function called "submit_post" which as far as I can tell is what's responsible for creating a post...

Code: Select all

        if ($post_mode == 'post')
        {
                $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' .
                        $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
                $db->sql_query($sql);

                $data['topic_id'] = $db->sql_nextid();

                $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
                        'topic_id' => $data['topic_id'])
                );
                unset($sql_data[TOPICS_TABLE]['sql']);
        }

        // Submit new post
        if ($post_mode == 'post' || $post_mode == 'reply')
        {
                if ($post_mode == 'reply')
                {
                        $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
                                'topic_id' => $data['topic_id'])
                        );
                }

                $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']);
                $db->sql_query($sql);
                $data['post_id'] = $db->sql_nextid();
See here how topic_id and post_id are set?

Therefore, the if block for the mod needs to be inserted AFTER submit_post has done the actual insert.. But wait, there's already functions for notifying people of posts in includes/functions_posting.php called user_notification which is called from submit_post..

Find:

Code: Select all

/**
* User Notification
*/
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
{
        global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;

        $topic_notification = ($mode == 'reply' || $mode == 'quote') ? true : false;
        $forum_notification = ($mode == 'post') ? true : false;
insert this after

Code: Select all

        if($config['enable_autopost']){
                $username = $config['twitter_username'];
                $password = $config['twitter_password'];
                $message = "Post:".$subject." ". generate_board_url()."/viewtopic.php?t=$topic_id";
                $url = 'http://twitter.com/statuses/update.xml';
                $curl_handle = curl_init();
                curl_setopt($curl_handle, CURLOPT_URL, "$url");
                curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
                curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl_handle, CURLOPT_POST, 1);
                curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
                curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
                $buffer = curl_exec($curl_handle);
                curl_close($curl_handle);
        }
INSTEAD of in posting.php
Last edited by lrgrthnlf on Wed Jun 03, 2009 12:46 am, edited 1 time in total.

User avatar
eqbeastlord
Registered User
Posts: 50
Joined: Thu Jan 02, 2003 2:45 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by eqbeastlord »

here is what i'm using right now to get to the right post... just going straight to the post.. not sure why the url that gets made doesn't like multiple items on the end.

Code: Select all

	if($config['enable_autopost'] && $forum_id !='132'){    
       $username = $config['twitter_username'];
       $password = $config['twitter_password'];


       $message = $subject." - ". generate_board_url()."/viewtopic.php?p=$post_id - ".$user->data['username'];
       $url = 'http://twitter.com/statuses/update.xml';
       $curl_handle = curl_init();
          curl_setopt($curl_handle, CURLOPT_URL, "$url");
          curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
          curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($curl_handle, CURLOPT_POST, 1);
          curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
          curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
          $buffer = curl_exec($curl_handle);
          curl_close($curl_handle);

User avatar
eqbeastlord
Registered User
Posts: 50
Joined: Thu Jan 02, 2003 2:45 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by eqbeastlord »

I updated this line:

Code: Select all

$message = $subject." - ". generate_board_url()."/viewtopic.php?p=$post_id - ".$user->data['username'];
so that it will no go DIRECTLY to the post

Code: Select all

$message = $subject." - ". generate_board_url()."/viewtopic.php?p=$post_id#p$post_id - ".$user->data['username'];

User avatar
phreakwars
Registered User
Posts: 239
Joined: Thu Feb 22, 2007 4:57 am
Location: Polaris Industries

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by phreakwars »

Neither one of those solutions worked for me.

lrgrthnlf's solution gave me an error in my includes/functions_posting.php (I am assuming I needed to remove the original code from posting.php).

And eqbeastlord's just simply did nothing.
.
.
MODS by me: Default Topic Icon

lrgrthnlf
Registered User
Posts: 58
Joined: Fri Jun 14, 2002 7:29 am
Location: Melbourne, Australia

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by lrgrthnlf »

phreakwars wrote:Neither one of those solutions worked for me.

lrgrthnlf's solution gave me an error in my includes/functions_posting.php (I am assuming I needed to remove the original code from posting.php).
What was the error? (Check your error log if Apache just says 500)... and yes, instead of modifying posting.php, my version modifies includes/functions_posting.php ..

User avatar
eqbeastlord
Registered User
Posts: 50
Joined: Thu Jan 02, 2003 2:45 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by eqbeastlord »

phreakwars wrote:Neither one of those solutions worked for me.

lrgrthnlf's solution gave me an error in my includes/functions_posting.php (I am assuming I needed to remove the original code from posting.php).

And eqbeastlord's just simply did nothing.
.
.
Mine is piggybacking off of lrgrthnlf's and editing the includes/functions_posting.php guess i should have made that clearer.

**EDIT**
btw: Here's my twitter feed so you can see what output i'm getting there: https://twitter.com/DWPCommunity

whocarez
Registered User
Posts: 146
Joined: Sat Apr 18, 2009 9:19 pm

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by whocarez »

Hello,

I had the problem, that my tweets were cut off, when I used double quotes in my titles. So when I had a title like that:

Code: Select all

ART: "blablabla"
where I should get something like that:

Code: Select all

ART: "blablabla" http://bit.ly/12345 - username
I got only:

Code: Select all

ART:
The solution is for me to put after the line:

Code: Select all

$message = $post_data['post_subject']." ". generate_board_url()."/viewtopic.php?t=$topic_id - ".$user->data['username'];
the following code:

Code: Select all

$message= urlencode(stripslashes(urldecode($message)));
Maybe it helps someone else ...

nish7X
Registered User
Posts: 11
Joined: Mon Apr 13, 2009 3:44 am

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by nish7X »

whocarez wrote:Hello,

I had the problem, that my tweets were cut off, when I used double quotes in my titles. So when I had a title like that:

Code: Select all

ART: "blablabla"
where I should get something like that:

Code: Select all

ART: "blablabla" http://bit.ly/12345 - username
I got only:

Code: Select all

ART:
The solution is for me to put after the line:

Code: Select all

$message = $post_data['post_subject']." ". generate_board_url()."/viewtopic.php?t=$topic_id - ".$user->data['username'];
the following code:

Code: Select all

$message= urlencode(stripslashes(urldecode($message)));
Maybe it helps someone else ...
Thanks, that happens quite a few times with mine! I'll try it out :)

User avatar
darkonia
Registered User
Posts: 1901
Joined: Tue May 13, 2008 1:10 pm
Location: Munich, Germany
Contact:

Re: [BETA] Twitter Auto Tweeter - 0.0.1

Post by darkonia »

whocarez wrote:Hello,

I had the problem, that my tweets were cut off, when I used double quotes in my titles. So when I had a title like that:

Code: Select all

ART: "blablabla"
where I should get something like that:

Code: Select all

ART: "blablabla" http://bit.ly/12345 - username
I got only:

Code: Select all

ART:
The solution is for me to put after the line:

Code: Select all

$message = $post_data['post_subject']." ". generate_board_url()."/viewtopic.php?t=$topic_id - ".$user->data['username'];
the following code:

Code: Select all

$message= urlencode(stripslashes(urldecode($message)));
Maybe it helps someone else ...
can you read???

then read the posts before your post...
MMOG-Heaven - Das Gaming Portal
Community bedeutet Gleichgesinnte finden - MMOG-Heaven ist Deine Community! Von Spielern für Spieler bietet Dir dieses Portal genau das, was ein Spieler braucht. Bleibe ständig informiert, finde die neuesten MMORPGs, oder suche die frischesten News aus der Welt des Online Gamings - dieses und vieles mehr erwartet Dich auf MMOG-Heaven.

Locked

Return to “[3.0.x] Abandoned MODs”