Archive for the 'PHP5' Category

GittiGidiyor API Client for Symfony Framework

Jul 15 2010 Published by Umut under PHP5

GittiGidiyor.com provides an API to make online business. You can find more information at Developer’s Website.

Here, I want to make some modifications on their PHP client to make it suitable with Symfony Framework. I prefer to use version 1.4 but it also works with older versions.

Please, add these settings to your app.yml:

all:
    gittigidiyor:
        apiKey: APPLICATION-KEY
        secretKey: SECRET-KEY
        nick: NICK
        password: PASSWORD
        authUser: AUTHENTICATION-USERNAME
        authPass: AUTHENTICATION-PASSWORD
        lang: LANGUAGE

Now, we can reach them via sfConfig::get(). This way is better than INI file while you’re working with Symfony Framework.

You can download the code at Github. By the way, I have modified only __construct method. If you want to make this modification yourself please replace the original __construct with the code below:

public function __construct(){
    $this->apiKey = sfConfig::get('app_gittigidiyor_apiKey');
    $this->secretKey = sfConfig::get('app_gittigidiyor_secretKey');
    $this->nick = sfConfig::get('app_gittigidiyor_nick');
    $this->password = sfConfig::get('app_gittigidiyor_password');
    $this->auth_user = sfConfig::get('app_gittigidiyor_authUser');
    $this->auth_pass = sfConfig::get('app_gittigidiyor_authPass');
    $this->lang = sfConfig::get('app_gittigidiyor_lang');
 
    list($usec, $sec) = explode(" ", microtime());
    $this->time = round(((float)$usec + (float)$sec) * 100).'0';
 
    $this->sign = md5($this->apiKey.$this->secretKey.$this->time);
}

No responses yet