Archive for February, 2010

SocialGo API

Thursday, February 18th, 2010

We’ll this post is for remembering one very important issue with the SocialGo API.

I was doing a webpage that send users to their SGo page. So I used the SGo API.

I downloaded it and realized that when you download the API the corresponding keys (developer and network) are already assigned to the corresponding properties so I was doing this:

$api = new SNM_api();

$id = ''; //. user email OR user ID
$result = $api->getUserCrossDomainAuthURL($id);
$redirect_user_url = $result->member->attributes()->auth_url;

I’ve been dealing with the fact that I kept getting false as a result… What’s wrong with the code?

So I went to the blogs, even the SocialGo blogs and some developers wrote me saying I needed to set the network and developer keys. I was reluctant because the object already had the pproperties set so I thought it was a silly answer, till minutes ago when I finally gave up trying other solutions. It worked! I haven’t takn a look to the SGo API but it looks that you need to set this properties in order for the API to work so the code ends up like this:

$api = new SNM_api();


$id = ''; //. user email OR user ID
$result = $api->getUserCrossDomainAuthURL($id);
$redirect_user_url = $result->member->attributes()->auth_url;
I'll never forget about this again.

call to undefined function json_decode

Sunday, February 14th, 2010

This sucks!

Again my dev env works perfectly and the production environment keeps throwing weird messages.

I’m using php json_decode to (you guessed it) decode  a json string. The server throws this ugly message!

What should I do?! Ok I realized my dev env uses PHP 5.2…. the production server uses 5.1.6. What does that have to do? Well for some reason PHP 5.1.6 doesn’t have json support, in order to support the calls you should either upgrade php or pear install it.

I tried updating to php 5.2, and didn’t worked so I ended installing the pear support.

Remember to include the proper paths.

Lock wait timeout exceeded; try restarting transaction

Sunday, February 14th, 2010

So last friday I came up with this nasty message… Believe me, it was a very troublesome issue to solve. We have MySQL running Innodb for a couple of tables. We wanted to modify 3 tables and we decided to create a transaction if inserts and updates went ok then commit if not rollback.

I did it and tested it on my dev env (my lap hehehehe) and it all worked fine, speed was ok and everything worked as wanted. So I commited it to my svn server and uploaded the code to the production server. 5 min. before I leave the office my boss decided to test the new version…. good and bad idea, good because he got the nasty error, bad because of the time.

Anyway, we saw the error. Initially I thought it was because of a web service (no, I didn’t realized it was a database issue), then after discarding lots of probable errors I realize it was a transaction error. After hours looking and reading google search results I learned the following: When doing a transaction tables involved receive a lock, the lock is released once the transaction ends. If a table is being updated within the transaction and you try to select data from it then you’ll be trying to access a locked table, since it is locked you can’t read from it and since you can’t read from it you can’t finish the transaction so the waiting for the lock to release takes for ever and the connection throws the error:

“Lock wait timeout exceeded; try restarting the transaction”

How did I solved it?

After trying docens of solutions without success I finally realized that I had to take the reading statements off the transaction.

It worked! And because I forget things very fast I decided to put it here.

Hope it helps someone else out there.