How to request access to a specific ChannelAdvisor Account using php

350 views
Skip to first unread message

jigneshkumar aakoliya

unread,
Mar 7, 2014, 1:44:24 AM3/7/14
to ca...@googlegroups.com
Hi friends .
I am trying to integrate magento with CA but throws authorization error..
Today i found that there is need to approve  request access to a  ChannelAdvisor Account so How can I do it..
thanks..

jigneshkumar aakoliya

unread,
Mar 7, 2014, 2:42:15 AM3/7/14
to ca...@googlegroups.com
I use following code but think that made only ping not request to accsess acount...


<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new nusoap_client('https://api.channeladvisor.com/ChannelAdvisorAPI/v1/inventoryService.asmx?WSDL', true );
// Check for an error
$err = $client->getError();
if ($err)
{     // Display the error     
 echo 'Constructor error' . $err . '';    
 // At this point, you know the call that follows will fail
 }
$developerKey = 'developerKey';
$password = 'Password';
$headers = '
        
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>'.$developerKey.'</web:DeveloperKey>
         <web:Password>'.$password.'</web:Password>
      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:RequestAccess>
         <web:localID>localID</web:localID>
      </web:RequestAccess>
   </soapenv:Body>
</soapenv:Envelope>

        ';
// Call the SOAP method
$result = $client->call('Ping', array(), false, false, $headers);
// Check for a fault
if ($client->fault){
       echo 'Fault';
    print_r($result);
    echo ''; 
}
else {
    // Check for errors
    $err = $client->getError();
    if ($err)
{          // Display the error   
       echo 'Error' . $err . '';      }
else
{          // Display the result 
         echo 'Result';

        print_r($result);
    echo '';      }
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';

// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>'; ?>

jigneshkumar aakoliya

unread,
Mar 7, 2014, 4:34:57 AM3/7/14
to ca...@googlegroups.com

now I am near to done just need one help...
need to know on which point i am wrong

ResultArray ( [RequestAccessResult] => Array ( [Status] => Failure [MessageCode] => 12 [Message] => No ChannelAdvisor Account was found for the specified ID [0]! [ResultData] => false ) )

Request

POST /ChannelAdvisorAPI/v7/AdminService.asmx HTTP/1.0
Host: api.channeladvisor.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "http://api.channeladvisor.com/webservices/RequestAccess"
Content-Length: 996

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header>
        
	  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>DeveloperKey</web:DeveloperKey>
<web:Password>
Password</web:Password>
</web:APICredentials> </soapenv:Header> <soapenv:Body> <web:RequestAccess> <web:localID>
AccountId/profile ID</web:localID> </web:RequestAccess> </soapenv:Body> </soapenv:Envelope> </SOAP-ENV:Header><SOAP-ENV:Body><RequestAccess xmlns="http://api.channeladvisor.com/webservices/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Response

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-ServerName: RDU-APPWEB-04
X-Powered-By: ASP.NET 
Date: Fri, 07 Mar 2014 09:30:28 GMT  

[ChannelAdvisor] Marshall McClure

unread,
Mar 7, 2014, 10:56:38 AM3/7/14
to ca...@googlegroups.com
I have a couple of concerns.  It looks like you have an envelope inside an envelope, so I doubt your XML is valid.  That could lead to the API thinking you are passing in zero for the localID parameter even if you are submitting a valid value.  You also should use HTTPS instead of HTTP so your communications with us are secure.  Here is a full example:

POST https://api.channeladvisor.com/ChannelAdvisorAPI/v7/AdminService.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://api.channeladvisor.com/webservices/RequestAccess"
Content-Length: 506
Host: api.channeladvisor.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>$developerkey</web:DeveloperKey>
         <web:Password>$password</web:Password>

      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:RequestAccess>
         <web:localID>$localID</web:localID>

      </web:RequestAccess>
   </soapenv:Body>
</soapenv:Envelope>

eweb

unread,
Aug 24, 2016, 4:51:31 AM8/24/16
to ChannelAdvisor Developer Network
Try this : - Note that you also need a profile id , the profile id you get from channel advisor account holder. this is 8 digits integer number.

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
// Check for an error
//var_dump($client); die;
$err = $client->getError();
if ($err)
{     // Display the error     
 echo 'Constructor error' . $err . '';    
 // At this point, you know the call that follows will fail
 }
$developerKey = 'developerKey';
$password = 'Password';
$profile_id  = "profile_id  ";
$headers = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>$developerKey</web:DeveloperKey>
         <web:Password>$password</web:Password>

      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:RequestAccess>
         <web:localID>$profile_id</web:localID>
Reply all
Reply to author
Forward
Message has been deleted
0 new messages