Twitter MOD version 2.0 - نوشته شده در (5302 Views)
Starting Member
iane87
مطلب: 42
42
Twitter MOD 2.0 has been released. It now uses the new OAuth authentication method which is now required by Twitter. The Twitter MOD will automatically post a tweet to Twitter every time someone posts on your forum with a shortened link back to the page where the entire post can be viewed. Also, upon deletion of a Reply, Topic, Forum or Category the related tweets will also be deleted.
Database modification is required, but the set up script will take care of this automatically.
This MOD will greatly increase traffic to your site.
You may download the Twitter MOD version 2.0 from:

http://freesupport.fixonefree.com/topic.asp?TOPIC_ID=489&CAT_ID=12
If you do not wish to create an account to download this file you may log in as
Username: demo
Password: demo

However, please create your own account if you would like to post on our forums.
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Starting Member
Lon
مطلب: 47
47
This MOD has my interest, however I think I may not have something setup correctly on my server. Any assistance would be appreciated.

ISSUE #1:
When I run http:\\mydomain.com\twittermod
I get the sign in with twitter, however when I press that link I get a popup window with this:

Server object error 'ASP 0178 : 80070005'

Server.CreateObject Access Error

/twittermod/oauth/cLibOAuth.Utils.asp, line 189

The call to Server.CreateObject failed while checking permissions. Access is denied to this object.


So I tried the same link on your example sites and it does bring up the correct popup window, so the issue is not with my local pc. Assuming the code is identical, that leaves permissions on my host server.


ISSUE #2:
The setup is not a typical mod setup where one would run from inside the forum, a direct run from twittersetup.asp, I received this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'IF'.

/twittermod/twittersetup.asp, line 33
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Save the following as "dbs_twitter.asp" and run from admin console:

Code:

Twitter Mod 2.0

[CREATE] TWEETS

REPLYID#VARCHAR(10)#NOTNULL##
TOPICID#VARCHAR(10)#NOTNULL##
FORUMID#VARCHAR(10)#NOTNULL##
CATID#VARCHAR(10)#NOTNULL##
TWITTERID#VARCHAR(20)#NOTNULL##
[END]
نوشته شده در
Starting Member
iane87
مطلب: 42
42
Issue #1

This is a permissions issue on your server. However, I think we can work around it. I would recommend that you comment out or delete the following lines of code from /twittermod/oauth/cLibOAuth.Utils.asp

Code:
Dim objWshShell : Set objWshShell = Server.CreateObject("WScript.Shell")
m_intOffsetMinutes = objWshShell.RegRead("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
Set objWshShell = Nothing

What the above code does is gets the time offset in minutes from GMT for your time zone. So you will need to figure out what that will be for your time zone. For example I'm on Mountain time which is 7 hours from GMT. So I would multiply 7 * 60 which equals 420. You will need to calculate this number based on your time zone. For Mountain Time zone I would replace the above code with this.
Code:
m_intOffsetMinutes = 420

If you still have problems you can try logging in via my web site at
http://freesupport.fixonefree.com/twittermod/
Then just copy your token and token secret from there into TwitterMOD/twitter.asp and then make a post to test and see if the tweet is posted to twitter.
Issue #2

Looks like my old setup script does not work on Microsoft SQL server. I designed and tested it on a MySQL server.
I have now included dbs_Twitter.asp in the download from my site to ensure compatibility with all databases. (same link as above) Copy this file to your forum directory and run this file through the MOD setup in the admin section of your forum. You may also use the code Carefree posted as they are essentially the same.
نوشته شده در
Starting Member
Lon
مطلب: 47
47
WOOT!!.. it's working...I guess I should have said I use MS SQL...
SOLVED Issue 1, I was able to log in on my server to Twitter, however it still does not issue the Oath Tokens from my system. I did use iane87's link and it worked. So you may still need to work on that part for others.
SOLVED Issue 2, thanks Carefree, that did the trick too.
--------------------------------------------------------
NOW>>>> Not really issues, more of How To's

Issue 3, How can I put in a filter to apply this to only a singel forum. I have a test/admin forum and a couple of private forums that should not be posted to Twitter.

Issue 4, The username is not posted on twitter, Is that by design?
نوشته شده در
Starting Member
iane87
مطلب: 42
42
#3

To make the Twitter MOD post only when the Auth Type of the forum is All Visitors look for the following blocks of code and add the code I marked green.


Code:
<!--#INCLUDE FILE="TwitterMOD/twitter/twitter.asp" -->
<!--#INCLUDE FILE="TwitterMOD/ShortURL.asp" -->
<%
Dim blnTweet



Code:

if MethodType = "Edit" or _
MethodType = "EditTopic" or _
MethodType = "Reply" or _
MethodType = "ReplyQuote" or _
MethodType = "Topic" or _
MethodType = "TopicQuote" then
if MethodType <> "Topic" then
'## Forum_SQL - Find out if the Category, Forum or Topic is Locked or Un-Locked and if it Exists
strSql = "SELECT C.CAT_STATUS, C.CAT_NAME, " &_
"F.FORUM_ID, F.F_STATUS, F.F_TYPE, F.F_SUBJECT, F.F_TOPIC_AUTH, " &_
"T.T_STATUS, T.T_AUTHOR, T.T_SUBJECT " &_
" FROM " & strTablePrefix & "CATEGORY C, " &_
strTablePrefix & "FORUM F, " &_
strActivePrefix & "TOPICS T" &_
" WHERE C.CAT_ID = T.CAT_ID " &_
" AND F.FORUM_ID = T.FORUM_ID " &_
" AND T.TOPIC_ID = " & Topic_ID & ""
else
'## Forum_SQL - Find out if the Category or Forum is Locked or Un-Locked and if it Exists
strSql = "SELECT C.CAT_STATUS, C.CAT_NAME, " &_
"F.FORUM_ID, F.F_STATUS, F.F_TYPE, F.F_SUBJECT, F.F_TOPIC_AUTH " &_
" FROM " & strTablePrefix & "CATEGORY C, " &_
strTablePrefix & "FORUM F" &_
" WHERE C.CAT_ID = F.CAT_ID " &_
" AND F.FORUM_ID = " & Forum_ID & ""
end if

set rsStatus = my_Conn.Execute(strSql)
if rsStatus.EOF or rsStatus.BOF then
rsStatus.close
set rsStatus = nothing
Go_Result fLang(strLangPost_Info00030), 0
else
blnTweet = rsStatus("F_TOPIC_AUTH") blnCStatus = rsStatus("CAT_STATUS")
strCatTitle = rsStatus("CAT_NAME")
blnFStatus = rsStatus("F_STATUS")
Forum_ID = rsStatus("FORUM_ID")
Forum_Type = rsStatus("F_TYPE")
strForum_Title = rsStatus("F_SUBJECT")
if MethodType <> "Topic" then
blnTStatus = rsStatus("T_STATUS")
strTopicAuthor = rsStatus("T_AUTHOR")
strTopicTitle = rsStatus("T_SUBJECT")
else
blnTStatus = 1
end if
rsStatus.close
set rsStatus = nothing
end if





Code:
'## Twitter Mod ##
if MethodType = "Topic" then
strReturnURL = "topic.asp?TOPIC_ID=" & NewTopicID
strReturnTxt = fLang(strLangPost_Info00770)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & NewTopicID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "Reply" or MethodType = "ReplyQuote" or MethodType = "TopicQuote" then
strReturnURL = "topic.asp?whichpage=-1&TOPIC_ID=" & Topic_ID & "&REPLY_ID=" & NewReplyID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (REPLYID, TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & NewReplyID & "', '" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "EditTopic" then
strReturnURL = "topic.asp?TOPIC_ID=" & Topic_ID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "Edit" then
strReturnURL = "topic.asp?whichpage=-1&TOPIC_ID=" & Topic_ID & "&REPLY_ID=" & Reply_ID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (REPLYID, TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & Reply_ID & "', '" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
else
strReturnURL = chkString(Request.Form("refer"),"refer")
strReturnTxt = fLang(strLangBack_Forum00010)
end if

if blnTweet = 1 then Dim strTweetURL, strBitURL, strTweetID
if instr(strTweetURL,"http") then
strTweetURL = strReturnURL
else
strTweetURL = strForumURL & strReturnURL
end if
strBitURL = " " & BitLy(strTweetURL)
strTweetID = Tweet(mid(txtMessage, 1, 140 - Len(strBitURL)) & strBitURL)
strSql = strSql & strTweetID & "')"
my_Conn.execute(strSql)
end if '## End Twitter Mod ##

#4

If you want to include member names in the posts you can change the following line of code. However, you are limited to 140 character posts with twitter. If the user has long username it can take up a good portion of your twitter post.
Code:
strTweetID = Tweet(mid(txtMessage, 1, 140 - Len(strBitURL)) & strBitURL)


to
Code:


strTweetID = Tweet(mid(txtMessage, 1, 138 - Len(strBitURL) - Len(strDBNTUserName)) & " " & strDBNTUserName & " " & strBitURL)
نوشته شده در
Starting Member
Lon
مطلب: 47
47
Excellent... I really appreciate your help on these. Oh, I think the twitter jpg is missing from the zipfile of version 2, I pulled mine from the first version.
Solved Issue 3, I tried to do what you posted, however my system stopped updating twitter and it just said POSTED. So I hard coded it to using
If FORUM_ID = 3 then
This solved my request and no other mods to the code, thou not a overall solution.
Solved Issue 4, I ended up using
strTweetID = Tweet(strDBNTUserName & ": " & mid(txtMessage, 1, 138 - Len(strBitURL) - Len(strDBNTUserName)) & " " & strBitURL)

-----------------------------------------
Which leads me to

Issue 5, the BitUrl is not posting. They seem to be posting in the public area in the BitLy web site, so the problem is probably the return of data or the posting of it to twitter.
نوشته شده در
Starting Member
iane87
مطلب: 42
42
Oh yeah I think I forgot to add the twitter logo in the new version. I'll update that tonight.
#3 Just realized that my above code will only work if you are running another MOD for forum authentication.
Try this instead for private forums

Code:
<!--#INCLUDE FILE="TwitterMOD/twitter/twitter.asp" -->
<!--#INCLUDE FILE="TwitterMOD/ShortURL.asp" -->
<%
Dim blnTweet



Code:

if MethodType = "Edit" or _
MethodType = "EditTopic" or _
MethodType = "Reply" or _
MethodType = "ReplyQuote" or _
MethodType = "Topic" or _
MethodType = "TopicQuote" then
if MethodType <> "Topic" then
'## Forum_SQL - Find out if the Category, Forum or Topic is Locked or Un-Locked and if it Exists
strSql = "SELECT C.CAT_STATUS, C.CAT_NAME, " &_
"F.FORUM_ID, F.F_STATUS, F.F_TYPE, F.F_SUBJECT, F.F_PRIVATEFORUMS, " &_
"T.T_STATUS, T.T_AUTHOR, T.T_SUBJECT " &_
" FROM " & strTablePrefix & "CATEGORY C, " &_
strTablePrefix & "FORUM F, " &_
strActivePrefix & "TOPICS T" &_
" WHERE C.CAT_ID = T.CAT_ID " &_
" AND F.FORUM_ID = T.FORUM_ID " &_
" AND T.TOPIC_ID = " & Topic_ID & ""
else
'## Forum_SQL - Find out if the Category or Forum is Locked or Un-Locked and if it Exists
strSql = "SELECT C.CAT_STATUS, C.CAT_NAME, " &_
"F.FORUM_ID, F.F_STATUS, F.F_TYPE, F.F_SUBJECT, F.F_PRIVATEFORUMS " &_
" FROM " & strTablePrefix & "CATEGORY C, " &_
strTablePrefix & "FORUM F" &_
" WHERE C.CAT_ID = F.CAT_ID " &_
" AND F.FORUM_ID = " & Forum_ID & ""
end if

set rsStatus = my_Conn.Execute(strSql)
if rsStatus.EOF or rsStatus.BOF then
rsStatus.close
set rsStatus = nothing
Go_Result fLang(strLangPost_Info00030), 0
else
blnTweet = rsStatus("F_PRIVATEFORUMS") blnCStatus = rsStatus("CAT_STATUS")
strCatTitle = rsStatus("CAT_NAME")
blnFStatus = rsStatus("F_STATUS")
Forum_ID = rsStatus("FORUM_ID")
Forum_Type = rsStatus("F_TYPE")
strForum_Title = rsStatus("F_SUBJECT")
if MethodType <> "Topic" then
blnTStatus = rsStatus("T_STATUS")
strTopicAuthor = rsStatus("T_AUTHOR")
strTopicTitle = rsStatus("T_SUBJECT")
else
blnTStatus = 1
end if
rsStatus.close
set rsStatus = nothing
end if





Code:
'## Twitter Mod ##
if MethodType = "Topic" then
strReturnURL = "topic.asp?TOPIC_ID=" & NewTopicID
strReturnTxt = fLang(strLangPost_Info00770)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & NewTopicID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "Reply" or MethodType = "ReplyQuote" or MethodType = "TopicQuote" then
strReturnURL = "topic.asp?whichpage=-1&TOPIC_ID=" & Topic_ID & "&REPLY_ID=" & NewReplyID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (REPLYID, TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & NewReplyID & "', '" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "EditTopic" then
strReturnURL = "topic.asp?TOPIC_ID=" & Topic_ID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
elseif MethodType = "Edit" then
strReturnURL = "topic.asp?whichpage=-1&TOPIC_ID=" & Topic_ID & "&REPLY_ID=" & Reply_ID
strReturnTxt = fLang(strLangPost_Info00780)
strSql = "INSERT INTO " & strTablePrefix & "TWEETS (REPLYID, TOPICID, CATID, FORUMID, TWITTERID) VALUES ('" & Reply_ID & "', '" & Topic_ID & "', '" & Cat_ID & "', '" & Forum_ID & "', '"
else
strReturnURL = chkString(Request.Form("refer"),"refer")
strReturnTxt = fLang(strLangBack_Forum00010)
end if

if blnTweet = 0 then Dim strTweetURL, strBitURL, strTweetID
if instr(strTweetURL,"http") then
strTweetURL = strReturnURL
else
strTweetURL = strForumURL & strReturnURL
end if
strBitURL = " " & BitLy(strTweetURL)
strTweetID = Tweet(mid(txtMessage, 1, 140 - Len(strBitURL)) & strBitURL)
strSql = strSql & strTweetID & "')"
my_Conn.execute(strSql)
end if '## End Twitter Mod ##

#5 You added another character to the tweet and twitter will cut you off after 140 characters so you need to adjust the code

Code:
strTweetID = Tweet(strDBNTUserName & ": " & mid(txtMessage, 1, 137 - Len(strBitURL) - Len(strDBNTUserName)) & " " & strBitURL)

If it is not posting the link at all make sure you updated shortURL.asp with your bitly username and API key.
To test the link shortenter put this in a file called test.asp in the TwitterMOD/twitter folder.
Code:
<!--#INCLUDE FILE="ShortURL.asp"-->
<%
response.write BitLy("http://fixonefree.com")
%>

If its working correctly you should see a shortened url appear.
نوشته شده در
Starting Member
Lon
مطلب: 47
47
Sweet... Thanks for your help.. It's nice to have a MOD that is up with modern day trends.
I have not added a MOD in years, I like working with code.
The Delete part does not work for me yet, however it is not much of a concern at this moment. I'll get back to you on that when I'm ready to tackle that.
So far my users love it.
نوشته شده در
Starting Member
iane87
مطلب: 42
42
Glad you liked it.
Twitter changed the text that was returned and my code was no longer storing the Tweet ID correctly.
I updated the code again. If you download the MOD from my site again and replace the file /TwitterMOD/twitter/twitter.asp on your site the deletion of tweets will start working again.
نوشته شده در
Junior Member
Zenfor
مطلب: 372
372
Originally posted by iane87
Twitter MOD 2.0 has been released...
Is this still ok to install? What exactly does it do? I am getting more and more information via twitter and was looking for a good way to incorporate it to my forum. Thanks!
شما باید یک متن وارد کنید