Adobe Connect User Community

Forums - Adobe Connect User Community

You are not logged in.     Log in to your ConnectUsers.com account.     Don't have an account? Sign up today

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

polydoro.cardozo
Member Rank:
New Member
What's This
Posts: 1

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 08:31:50

jasonheffner
Member Rank:
Participant
What's This
Posts: 25

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

Code:

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 08:42:57)

Offline

 

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

chrisbrad
Member Rank:
New Member
What's This
Posts: 1

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....

Thanks.........


Movie theater tickets are available here.
You can enjoy Movie Theaters Virginia.

Offline

 

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

alainr
Member Rank:
Participant
What's This
Posts: 10

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

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson