Adobe Connect User Community
Menu

#1 2009-11-19 14:09:17

**_polydoro.cardozo_**

Use API to connect through custom app

I am having problems when I try to login through custom app

<results>
<status code="no-data"/>
</results>

I am trying to do it with PHP.

Does someone know a tutorial (PHP example) to do it ? I think its because cookie value changes.

https://connectpro16243578.acrobat.com/api/xml?

action=login&login=myname

&password=mypass

&account-id=1011760728

&session=na1breezhg7ph2dmkokzgetx

Offline

#2 2009-11-24 11:31:50

**_jasonheffner_**

Re: Use API to connect through custom app

Edit: No data is what you get with a failed request

We use ASP/ASP.NET to login in accounts against the api. If you are using session management you shouldn't send the account-id with your request. I've found it easier to use cookie management when logging in an account instead of session management. With cookie management the login call returns a session cookie that you can set through PHP on the local users computer. You can also log in an admin account in your code, and pass an admin session with your xml request for additional tasks without having to worry about the user gaining these privileges.

7.0 api doc - http://www.adobe.com/support/documentat … onnectpro/

Here is example code in ASP, maybe someone has it in PHP

const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056

breezeurl = "https://" & DomainName & "/api/xml?action=login&login=" & BreezeLogin & "&password=" & BreezePassword
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open "POST", breezeurl, False
xml.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xml.Send

' Check Status code after attempted login
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.loadxml xml.responseTEXT
StatusCode = objXMLDoc.selectSingleNode("/results/status").Attributes.GetNamedItem("code").Text
If StatusCode = "ok" Then
    ' Set cookie for successful login and get session value
    Response.Addheader "Set-Cookie", xml.getResponseHeader("Set-Cookie")
    LogMessage = Request.ServerVariables("REMOTE_ADDR") & "," & BreezeLogin & " successfully logged in" 
    Logger(LogMessage)
Else
    ' Error logging in user, user account doesn't exist or password is incorrect.
    ErrorCode = 1
End If
Set objXMLDoc = Nothing
Set xml = Nothing

Last edited by **_jasonheffner_** (2009-11-24 11:42:57)

Offline

#3 2010-07-30 14:46:18

**_chrisbrad_**

Re: Use API to connect through custom app

That's nice, jasonheffner :)


You have posted that I need now....

I also use ASP to log in account against api....

Sandwich Delivery London


Thanks.........

Last edited by **_chrisbrad_** (2012-10-26 13:46:01)

Offline

#4 2010-08-11 06:30:26

**_alainr_**

Re: Use API to connect through custom app

Hi There,

I use  PHP, I have written a *really basic* class to do it for you:

here's how to use it:

$connectPro = new ConnectProAdmin( USERNAME, PASSWORD, BASE_URL );

$connectPro->directAPICall(   "some api call"   );

cheers

Alain



class ConnectProAdmin {
    public $curl_handle;
    public $baseURL;
    public $cookie;

    function __construct($email = CONNECTPRO_ADMIN_LOGIN,$password = CONNECTPRO_ADMIN_PASSWORD,$adobeBaseURL = CONNECTPRO_BASE_URL) {
        $curl_handle = null;
        $this->baseURL = $adobeBaseURL;

        $this->curl_handle = curl_init();

        if( !isset($this->cookie) ) {
            $this->setupAdobeSessionCookie();

                        /* Login to the API service */
                        $buffer = null;
                        $loginURL = null;

                        $loginURL = $this->baseURL . "api/xml?action=login&login=" . $email .
                                                "&password=" . $password . "&session=" . $this->cookie;

                        curl_setopt($this->curl_handle, CURLOPT_URL, $loginURL );
                        curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT , 4);
                        curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER , 1);
                        $buffer = curl_exec($this->curl_handle);

                        $xmlObj = unserialize_xml($buffer);
                        if( $xmlObj["status"]["@attributes"]["code"] != "ok" ) {
                                Throw new Exception('ADOBE CONNECT PRO LOGIN ERROR = returned code was ' . $xmlObj["status"]["@attributes"]["code"]);    // TODO: check $xmlObj for login failure
                        }
        }
    }

    function __destruct() {
        if($this->curl_handle != null)
            curl_close($this->curl_handle);
    }

        public function getSessionCookie() {
            return ($_COOKIE['BREEZESESSION'] == "") ? $this->cookie : $_COOKIE['BREEZESESSION'];
        }

    private function setupAdobeSessionCookie() {
        $returnBuffer = null;
        curl_setopt($this->curl_handle, CURLOPT_URL, $this->baseURL . "api/xml?action=common-info");
        curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT , 4);
        curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER , 1);
        $returnBuffer = curl_exec($this->curl_handle);        // TODO: Put a try/catch block here to catch errors

        // Grab the Cookie out of the server XML response
        $xmlObj = simplexml_load_string($returnBuffer);
        $this->cookie = $xmlObj->common->cookie;
    }

    /**
         * Make a direct call to Adobe API
     */
    public function directAPICall($apiURL) {
        curl_setopt($this->curl_handle, CURLOPT_URL, $this->baseURL . $apiURL . "&session=" . $this->getSessionCookie() );
        curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT , 4);
        curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER , 1);

        return curl_exec($this->curl_handle);   /* Returns XML response string */
    }
}

Offline

#5 2011-06-18 15:15:02

**_taimi011_**

Re: Use API to connect through custom app

Thank you alainr ,

$connectPro = new ConnectProAdmin( USERNAME, PASSWORD, BASE_URL );

$connectPro->directAPICall(   "some api call"   );

Work good thanks for sharing it with us. :)

Last edited by **_taimi011_** (2012-02-13 09:40:27)

Offline

#6 2012-10-17 09:09:16

**_drakk_**

Re: Use API to connect through custom app

hello,

I used your class and modified a bit the content in order to get id_account aswell.
Anyway, I cant log in even if the status code is "ok". Is it linked to cURL properties?
on the other end, i can connect if i copy & paste the  $loginURL directly in the header but of course i dont want to set password and login visible. Should i use http request? help please. thx

Last edited by **_drakk_** (2012-10-17 09:11:43)

Offline

Board footer