Incorrect parameters error when in PHP script but working when pasted into browser

123 views
Skip to first unread message

Jamie Davies

unread,
Mar 8, 2013, 10:45:07 AM3/8/13
to slideshare...@googlegroups.com

Hello. 

I am banging my head against a wall at the moment. I am using the codeigniter port of the slideshare php wrapper for the api and it is working well for all other functions. I am trying to have a script upload a file to slideshare and keep getting the following error returned: 

Array ( [0] => Array ( [Error] => true [Message] => Incorrect parameters ) )

However, if I paste the URL that is being called by the following function into a browser it works with no issues and returns the ssid of the file as I would expect. 


   private function get_data($call, $params) {
        $ts = time();
        $hash = sha1($this->secret . $ts);
        try {
            $res = $this->file_get_contents_utf8($this->apiurl . $call . "?api_key=$this->key&ts=$ts&hash=$hash" . $params);
        } catch (Exception $e) {
            // Log the exception and return $res as blank
        }
        return utf8_encode($res);
    }

    // Upload slide to slideshare
    public function upload_slide( $params ) {
        
        $strparams = $this->prepare_url($params);
        $data = $this->XMLtoArray($this->get_data("upload_slideshow", "&" . $strparams));
        return $data;
        
        
    }

Any help or advice would be appreciated. 

Many thanks, 

Jamie 

Jamie Davies

unread,
Mar 9, 2013, 3:32:16 PM3/9/13
to slideshare...@googlegroups.com


After lots of debugging it was an issue with the $params that were being passed through. Both the upload_url and the title needed wrapping in urlencode() before passing through or it was terminating the url that was being then called by file_get_contents thus the incorrect parameters being through back. 
Reply all
Reply to author
Forward
0 new messages