Note that there are some explanatory texts on larger screens.

plurals
  1. POPass parameter as an object[]
    text
    copied!<p>I wish to use this API with a c# application: <a href="http://www.affjet.com/2012/11/26/4-4-affjet-api/#more-3099" rel="noreferrer">http://www.affjet.com/2012/11/26/4-4-affjet-api/#more-3099</a></p> <p>After adding the wsdl to my projcet i wrote this simple code : (getTransactions gets a object[] @params and returns a string)</p> <pre><code>Ws_ApiService service = new Ws_ApiService(); string apiKey = "*************"; var response = service.getTransactions(new object[] { apiKey }); </code></pre> <p>i tried few more ways but couldnt get a right response, i tried :</p> <pre><code>var response = service.getTransactions(new object[] { "apiKey:****"}); </code></pre> <p>and </p> <pre><code>var response = service.getTransactions(new object[] { "apiKey","******"}); </code></pre> <p>Here is the php code that does the same from their docs :</p> <pre><code>&lt;?php $nameSpace = "https://secure.affjet.com/ws/api"; //Creating AffJet client for SOAP $client = new SoapClient($nameSpace."?wsdl"); $pageNumber = 0; //Setting up parameters $params = array(); $params["apiKey"] = "MY_API_KEY"; //Value for parameters (optional) //$params["networkId"] = array(1,2); //$params["pageNumber"] = 0; //$params["pageSize"] = 10; //Making Request $response = $client-&gt;getNetworks($params); //XML to SimpleXMLElement Object $xmlResponse = new SimpleXMLElement($response); if ($xmlResponse-&gt;success == "true"){ while (isset($xmlResponse-&gt;dataList-&gt;data)) { //Iterate the results foreach ($xmlResponse-&gt;dataList-&gt;data as $data){ var_dump(xml2array($data)); } //Requesting next page of data $pageNumber++; $params["pageNumber"] = $pageNumber; //Making Request $response = $client-&gt;getNetworks($params); //XML to SimpleXMLElement Object $xmlResponse = new SimpleXMLElement($response); } } else { //Error somewhere echo $xmlResponse-&gt;errorMessage; } /** * Transforms the object SimpleXmlElement into an array, easier to handle */ function xml2array($xml) { $arr = array(); foreach ($xml as $element) { $tag = $element-&gt;getName(); $e = get_object_vars($element); if (!empty($e)) { $arr[$tag] = $element instanceof SimpleXMLElement ? xml2array($element) : $e; } else { $arr[$tag] = trim($element); } } return $arr; } ?&gt; </code></pre> <p>this was the response for what i tried :</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://secure.affjet.com/ws/api" 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getTransactionsResponse&gt; &lt;return xsi:type="xsd:string"&gt; &amp;lt;response&amp;gt;&amp;lt;success&amp;gt;false&amp;lt;/success&amp;gt;&amp;lt;errorMessage&amp;gt; API Key not provided&amp;lt;/errorMessage&amp;gt;&amp;lt;dataList&amp;gt; &amp;lt;/dataList&amp;gt;&amp;lt;/response&amp;gt; &lt;/return&gt; &lt;/ns1:getTransactionsResponse&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>you can see : </p> <pre><code>API Key not provided </code></pre> <p>And the response should be something like this:</p> <pre><code>&lt;response&gt; &lt;success&gt;true&lt;/success&gt; &lt;errorMessage&gt;&lt;/errorMessage&gt; &lt;dataList&gt; &lt;data&gt; &lt;date&gt;2012-11-05 15:02:41&lt;/date&gt;//Transaction Date &lt;amount&gt;81.67&lt;/amount&gt; &lt;commission&gt;15.86&lt;/commission&gt; &lt;status&gt;confirmed&lt;/status&gt;//Status, could be: declined, pending, confirmed or paid &lt;clickDate&gt;&lt;/clickDate&gt; &lt;ip&gt;&lt;/ip&gt; &lt;custom_id&gt;MyCustomId&lt;/custom_id&gt;//Custom Id for the transactions (SID, SubId,clickRef....) &lt;unique_id&gt;2548462&lt;/unique_id&gt;//Unique Id given from the network to this transaction &lt;merchantId&gt;1&lt;/merchantId&gt;//Id for the Merchant on AffJet &lt;networkId&gt;1&lt;/networkId&gt;//Id for the Network on AffJet &lt;/data&gt; &lt;/dataList&gt; &lt;/response&gt; </code></pre> <p>all i need to supply is a parameter named "apiKey" and its value</p> <p>EDIT :</p> <p>after contacting their support, they said the request should look like this :</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://secure.affjet.com/ws/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP- ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getTransactions&gt; &lt;params xsi:type="ns2:Map"&gt; &lt;item&gt; &lt;key xsi:type="xsd:string"&gt;apiKey&lt;/key&gt; &lt;value xsi:type="xsd:string"&gt;YOURAPIKEY&lt;/value&gt; &lt;/item&gt; &lt;/params&gt; &lt;/ns1:getTransactions&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Any ideas ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload