• September 20, 2010

    PHP’s ZipArchive and zip archives made on OSX gotcha

    Think happy posts! :) While trying to to unzip (extract) with php v5.3, which are made on osx using builtin ZipArchive library, I've encountered mysterious problem. ZipArchive was seeing dir (folder) separators and filenames inside zip archive in a really screwed up way:

    dizajn publikacija:jelovnik/1:poc?etna.jpg -> this is a folder "dizajn publikacija" subfolder "jelovnik" and file "1_početna.jpg"
    1:poc?etna.jpg - file with a name "1_početna.jpg"

    Encoding problem of some sort obviously, but I really didn't have time to find which one (if that really is the case or maybe I've again scored a new undocumented bug).
    read more

  • September 3, 2010

    Facebook PHP SDK access token signing bug

    So if you are getting

    The method you are calling or the FQL table you are querying cannot be called using a session secret or by a desktop application.

    while trying to run some old facbook REST API while using new php sdk this post is for you!

    Truth is the some REST calls dose not have new graph equivalent. Like for example dashboard.addGlobalNews.

    SDK even in new 2.1.1. version still dose not know how to sign old REST api calls.

    When making a call SDK internally calls getAccessToken method to get token.
    If you mix new graph api with old REST api internal check for type of api message signing will go havoc.

    So quick and dirty solution, add override to facebook SDK and thank them for making it open source.

    Add this property to facebook sdk class:


    public $overrideToAppSigned = false;

    and change getAccessToken method to:

    public function getAccessToken() {
    $session = $this->getSession();
    // either user session signed, or app signed
    if ($session && !$this->overrideToAppSigned) {
    return $session['access_token'];
    } else {
    return $this->getAppId() .'|'. $this->getApiSecret();
    }
    }

    Now you can call old REST api like this:

    $this->_facebook->overrideToAppSigned = true;

    $result = $this->_facebook->api(
    array(
    'method' => 'dashboard.addGlobalNews',
    'call_id' => microtime(true),
    'news' => $news
    )
    );

    $this->_facebook->overrideToAppSigned = false;

    Don't forget the last line! ;)

Proudly running on Word Press, and above all, proudly using Comic Sans.

Nivas.hr © Copyright 2009    All right reserved    Made in Croatia Yeah, we made our own site!Nivas.hr