Automatically publish products on Twitter

With the following PHP script, when we add new product in Zen Cart, it will automatically publish the product on Twitter.

(It can be added to /admin/includes/modules/update_product.php )

// BOF twitter feed
    
    if ($action == 'insert_product')
    {
      $purl = zen_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id);
      $tinyPurl = file_get_contents('http://tinyurl.com/api-create.php?url='.$purl);
      function updateStatus($user, $password, $message)
      {
        $url = "http://twitter.com/statuses/update.xml";
        $curl = curl_init($url);
        $data = array('status'=>$message);
        curl_setopt($curl, CURLOPT_USERPWD, $user.':'.$password);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
        $result = @curl_exec($curl);
        curl_close($curl);
        return $result;
      }
      $message = STORE_NAME . ' has a new product. ' . $tinyPurl;
      $user = 'YYYYYYYYY';
      $password = 'XXXXXXXXX';
      $result = updateStatus($user, $password, $message);
      $messageStack->add_session($result, 'error');
    }
    // EOF twitter feed

Upgrade PCRE on CentOS

PCRE – Perl Compatible Regular Expressions

I was trying to install an application on server today and received the following error message:

PHP is linked to a version of the PCRE library that does not support Unicode properties. If you are running Red Hat Enterprise Linux / CentOS 5.4 or earlier, see our documentation page on fixing this.

The CentOS version is 5.5.

SSH to the server and check version:

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

It shows Unicode is not supported by PCRE library

I have to download the latest PCRE library and run

./configure –prefix=/usr –enable-utf8 –enable-unicode-properties
make
make install

check the system again:

# pcre-config –version
8.10

Great! but…

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

Why it still shows the old version 6.6? The output from pcre-config and pcretest are different.

Finally found an answer with Google: The old library was still in folder /lib/

# locate libpcre
> > /lib/libpcre.so.0
> > /lib/libpcre.so.0.0.1
> > /usr/lib/libpcre.a
> > /usr/lib/libpcre.la
> > /usr/lib/libpcre.so
> > /usr/lib/libpcre.so.0

First unlink /lib/libpcre.so.0
Then rename /lib/libpcre.so.0.0.1 to something else (or just delete it)
problem resolved

# pcretest -C
PCRE version 8.10 2010-06-25
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

VoIP 电话、Linksys PAP2、vbuzzer

今天买了个linksys的PAP2,装了网络电话,效果很好。

网关采用解锁的PAP2,用于将普通电话连到网络上,通话质量感觉比普通电话线路还要好。如果你想省钱,直接用电脑打电话当然也可以,但是效果差多了,而且整天打电话时电脑要开着,不方便。

网络电话服务商用的是:Vbuzzer
这家公司的长途价格很不错,而且以$2/月的价格提供北美当地电话号码,应该是最便宜的了。就是说,你也可以拥有国外的本地电话,那么国外客户联系你就不用打国际长途了。