Textpattern Forum

You are not logged in. Register | Login | Help

#111 2010-08-23 18:21:42

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,197
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

I also found difficulties since I use several Twitter accounts – I first had to sign out of Twitter before arc_twitter was able to connect to Twitter. That was problematic because Twitter was not destroying the session effectively. But it all works in the end!


TXP Tips | @txptips

TXP Builders – finely-crafted code, design and txp @txpbuilders

Offline

#112 2010-08-23 18:27:33

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 192
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

jstubbs wrote:

I also found difficulties since I use several Twitter accounts – I first had to sign out of Twitter before arc_twitter was able to connect to Twitter. That was problematic because Twitter was not destroying the session effectively. But it all works in the end!

Unfortunately there’s not a lot that can be done about the sign-in process as it is part of Twitter’s new authentication system. It is meant to reassure the end user that they are using a genuine Twitter app I believe.

I am busily putting together version 2 of the plugin which will have loads of new features including the new Tweet button (I have that working in an alpha version of the plugin if anyone’s interested in testing it out). The focus is very much on the front-end aspects of the plugin, but if I have chance I will try and address the multisite issue that people are experiencing.

Offline

#113 2010-08-23 22:50:22

johnnie
Member
Registered: 2007-03-10
Posts: 58

Re: TXP Tweet: arc_twitter and arc_twitter_intents

First of all, thank you for this great plugin.

I’d like to contribute a bit, because I ran into a problem related to the usage of file_get_contents to grab the shortened URL. file_get_contents is disabled on many hosts due to safety concerns and is supplanted by cURL, which is the new standard for inter-domain requests. I have therefore done a slight rewrite of your URL shorten-function to make use of cURL instead of the file_get_contents. Perhaps useful to those who can’t get tinyURL or is.gd to work because of host restrictions:

/*
 * Shorten URLs using various methods
 */
function arc_shorten_url($url, $method='', $atts=array())
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);

   switch ($method) {
        case 'smd': // create a shortened URL using SMD Short URL
            return ($atts['id']) ? hu.$atts['id'] : false; break;
        case 'isgd':

            $u = 'http://is.gd/api.php?longurl='.urlencode($url);
            curl_setopt($ch, CURLOPT_URL, $u);

            $tinyurl = curl_exec($ch);
            if ($tinyurl!='Error' && $tinyurl!='') {
                return $tinyurl;
            } else {
                trigger_error('arc_twitter failed to get a is.gd URL for '
                    .$url,E_USER_WARNING);
            }
            break;

        case 'tinyurl': default: // create a shortened URL using TinyURL

            $u = 'http://tinyurl.com/api-create.php?url='.urlencode($url);
            curl_setopt($ch, CURLOPT_URL, $u);
            $tinyurl = curl_exec($ch);
            if ($tinyurl!='Error' && $tinyurl!='') {
                return $tinyurl;
            } else {
                trigger_error('arc_twitter failed to get a TinyURL for '.$url,E_USER_WARNING);
            }

    }

    return false; // fail

}

Offline

#114 2010-08-24 18:40:48

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 192
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

johnnie wrote:

First of all, thank you for this great plugin.

I’d like to contribute a bit, because I ran into a problem related to the usage of file_get_contents to grab the shortened URL. file_get_contents is disabled on many hosts due to safety concerns and is supplanted by cURL, which is the new standard for inter-domain requests. I have therefore done a slight rewrite of your URL shorten-function to make use of cURL instead of the file_get_contents. Perhaps useful to those who can’t get tinyURL or is.gd to work because of host restrictions:

Big thank you for the contribution, I’ve thrown it into the first alpha release of version 2 of arc_twitter for testing purposes. I really welcome code contributions if people have them and they help further and improve the functionality of the plugin.

For those of you interested in testing/trying out the version 2 alpha, or just want to learn the direction the plugin is going, I’ve just posted details about it over on my blog. You can also test out the retweet functionality on the post (there’s a “Tweet this” link on the left-hand-side of the page).

Offline

#115 2010-08-24 19:13:43

johnnie
Member
Registered: 2007-03-10
Posts: 58

Re: TXP Tweet: arc_twitter and arc_twitter_intents

monkeyninja wrote:


Big thank you for the contribution, I’ve thrown it into the first alpha release of version 2 of arc_twitter for testing purposes. I really welcome code contributions if people have them and they help further and improve the functionality of the plugin.

For those of you interested in testing/trying out the version 2 alpha, or just want to learn the direction the plugin is going, I’ve just posted details about it over on my blog. You can also test out the retweet functionality on the post (there’s a “Tweet this” link on the left-hand-side of the page).

Hi Andy,

Thanks for the acknowledgement. I think I also spotted a small bug that might cause URL shrinking to fail for people who use the custom URL field. It is in the part where you select the article from the database, right before feeding it to permlink(). Do you have any particular reason to just select a few columns in the safe_row call? The problem is, that if you don’t select the custom url field along with the article, the permlink() function will create the permlink using the default permlink scheme instead of using the custom URL field the user may have entered. This will mess things up, since the constructed URL will then 404. I replaced the column names with a simple ‘*’ to fix this issue, so now the safe_row call before the URL shortening is invoked looks like this:

$article = safe_row("*", 'textpattern',
            "ID={$article_id} AND Status=4 AND now()>=Posted");

Last edited by johnnie (2010-08-24 19:17:11)

Offline

#116 2010-08-24 20:07:19

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 1,623
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

arc_twitter v2 is looking sweet, will definitely be installing that.

Is there any chance this could be made to work with bot_write_tab_customize? in that I only really need to display the twitter option for authors in specific sections when writing an article (for example a blog article or news article).

Offline

#117 2010-08-26 17:38:20

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 192
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

philwareham wrote:

arc_twitter v2 is looking sweet, will definitely be installing that.

Is there any chance this could be made to work with bot_write_tab_customize? in that I only really need to display the twitter option for authors in specific sections when writing an article (for example a blog article or news article).

I will investigate as I can see that this could be very useful, but I don’t have much knowledge of bot_write_tab_customize so no guarantees.

Offline

#118 2010-09-09 14:32:06

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,197
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

Andy,

Would it be possible/feasible to add a tweet from an article being moderated (mem_moderation)? Its not a big deal but its an extra step (moderate an article, then visit the Write tab to send a tweet from the article) and not the most elegant solution.


TXP Tips | @txptips

TXP Builders – finely-crafted code, design and txp @txpbuilders

Offline

#119 2010-09-22 02:16:42

trailgirl
Member
Registered: 2004-06-04
Posts: 68
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

I was running an older version of arc_twitter which I turned off and then deleted and installed version 1.0.4 When I go to options to log into Twitter I get this message:

Fatal error: Call to undefined function hash_hmac() in [actual path removed]/textpattern/lib/txplib_misc.php(594) : eval()’d code on line 1307

I deleted 1.0.4 and installed 2.0Alpha 1 but still get the same error.

I am running Txp 4.2.0

Any suggestions?

Offline

#120 2010-10-18 18:19:07

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: TXP Tweet: arc_twitter and arc_twitter_intents

Few things that caught me on installing this plugin.

I also found difficulties since I use several Twitter accounts – I first had to sign out of Twitter before arc_twitter was able to connect to Twitter. That was problematic because Twitter was not destroying the session effectively. But it all works in the end!

That happened to me too. When clicking on the “Sign in to Twitter” link, on the Options page for arc_twitter, I was being redirected back to TXP admin.
I had to sign out of Twitter, then click on the “Sign in to Twitter” link, login to Twitter using my user/pass, and then it worked. My Twitter account was successfully configured on Textpattern.

I think that a simple, short note, both in Plugin’s help and next to the “Sign in to Twitter” link, saying “(you may need to log out from your Twitter account first, for the configuration process to work)” may really help.

Re: /textpattern/ vs /admin/, on multi-site installs.

Adding this to your .htaccess:

Redirect 301 /textpattern /admin

Should be enough to fix any plugin/script/stuff, not just arc_twitter, that has /textpattern hardcoded on it. It worked flawlessly for me on a few TXP installs.
(There you have a TXPTip, Jonathan! :) )

@Andy, I think arc_twitter should honor, if possible, the tempdir preference (on Admin -> Advanced Preferences), not the usual default (/textpattern/tmp) as arc_twitter currently does, when not specifying a particular caching directory for arc_twitter.

Last edited by maniqui (2010-10-18 18:19:39)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB