SOAP commissie ophalen

Gestart doorRemcoboy12 reacties106 weergaven

13 berichten · pagina 1 van 1

Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Daisycon heeft een API in SOAP om de transacties uit te lezen.

WSDL link: http://api.daisycon.com/publisher/soap/transaction/wsdl/

Voorbeeld script van Daisycon
Spoiler tonen
[COLOR= #0000BB]<?php 
     
    $sWsdl[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://api.daisycon.com/publisher/soap/transaction/wsdl/"[/COLOR][COLOR= #007700];[/COLOR]      
    [COLOR= #0000BB]$aOptions[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL] 
    [COLOR= #007700]([/COLOR]  
        [COLOR= #DD0000]login[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #DD0000]user[/COLOR][COLOR= #007700],[/COLOR] 
        [COLOR= #DD0000]password[/COLOR] [COLOR= #007700]=>[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]pass[/COLOR] [COLOR= #007700]),[/COLOR] 
        [COLOR= #DD0000]features[/COLOR] [COLOR= #007700]=>[/COLOR] SOAP_SINGLE_ELEMENT_ARRAYS[COLOR= #007700],[/COLOR]  
        [COLOR= #DD0000]encoding[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #DD0000]utf-8[/COLOR][COLOR= #007700],[/COLOR]  
        [COLOR= #DD0000]trace[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700], 
    );[/COLOR] 
    [COLOR= #0000BB]$oSoapClient[/COLOR] [COLOR= #007700]= new[/COLOR] SoapClient[COLOR= #007700]([/COLOR] [COLOR= #0000BB]$sWsdl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aOptions[/COLOR] [COLOR= #007700]);[/COLOR] 
                             
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<pre>"[/COLOR][COLOR= #007700];[/COLOR]  
    [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/var_export"]var_export[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR] [COLOR= #007700]) .[/COLOR][COLOR= #DD0000]"<hr>"[/COLOR][COLOR= #007700];[/COLOR] 
                             
    [COLOR= #0000BB]$aFilter[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL] 
    [COLOR= #007700]([/COLOR] 
        [COLOR= #DD0000]selection_start[/COLOR]    [COLOR= #007700]=>[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]Y-m-d[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/strtotime"]strtotime[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]-3 months[/COLOR] [COLOR= #007700]) ),[/COLOR] 
        [COLOR= #DD0000]selection_end[/COLOR] [COLOR= #007700]=>[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]Y-m-d[/COLOR] [COLOR= #007700]),[/COLOR] 
        [COLOR= #DD0000]status[/COLOR] [COLOR= #007700]=>[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]open[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]approved[/COLOR] [COLOR= #007700]),[/COLOR] 
        [COLOR= #DD0000]limitCount[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700], 
    );[/COLOR] 
                             
    try 
    [COLOR= #007700]{[/COLOR] 
        [COLOR= #0000BB]$mResult[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]getTransactions[COLOR= #007700]([/COLOR] [COLOR= #0000BB]$aFilter[/COLOR] [COLOR= #007700]); 
    }[/COLOR] 
    catch[COLOR= #007700]([/COLOR] Exception [COLOR= #0000BB]$e[/COLOR] [COLOR= #007700]) 
    {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]__getLastRequestHeaders[COLOR= #007700]() );[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]__getLastResponse[COLOR= #007700]() ); 
    }[/COLOR] 
                             
    [URL="http://www.php.net/var_dump"]var_dump[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$mResult[/COLOR] [COLOR= #007700]);[/COLOR] 
     
    ?>
Waarom werkt mijn foreach niet?

[COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]getTransactions[COLOR= #007700]([/COLOR] [COLOR= #0000BB]$aFilter[/COLOR] [COLOR= #007700])) as[/COLOR] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]) {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]->[/COLOR]commission[COLOR= #007700]; 
                }[/COLOR] 
?>
0
Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je hebt een ) te veel
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kjeld schreef:
Je hebt een ) te veel
[COLOR= #0000BB]<?[/COLOR]
    [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]getTransactions[COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFilter[/COLOR][COLOR= #007700]) as[/COLOR] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]) {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]->[/COLOR]commission[COLOR= #007700]; 
    }[/COLOR]
?>


Deze werkt (==geen error).
Maar dan krijg ik geen output.
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
doe eens var_dump($transaction) dan en post wat je krijgt
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Haal je niet continu een nieuwe array / nieuwe objecten op omdat je $oSoapClient->getTransactions($aFilter) telkens opnieuw uitvoert?

Ik zou eerst de gettransactions in een var zetten, en vanuit daar verder gaan debuggen:

[COLOR= #0000BB]<?
    $tempVar[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]getTransactions[COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFilter[/COLOR][COLOR= #007700]);[/COLOR]

    [URL="http://www.php.net/var_dump"]var_dump[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tempVar[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// Krijgen we hier de verwachte output; krijgen we een object terug ?[/COLOR]

    [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$tempVar[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]) {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]->[/COLOR]commission[COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Indien het een object is werkt dit. Anders moet je bijvoorbeeld met een arraynotatie werken. [/COLOR]
    [COLOR= #007700]}[/COLOR]
?>


Volgens mij krijg je namelijk een array terug, geen object. Dan zou je dus $transaction[commission] moeten doen.
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
doe eens var_dump($transaction) dan en post wat je krijgt
object(stdClass)#43 (5) {
  ["totalResults"]=>
  int(38)
  ["startOffset"]=>
  int(1)
  ["endOffset"]=>
  int(38)
  ["requestTime"]=>
  int(1)
  ["message"]=>
  NULL
}


toevoeging op 10 mei 2013, 13:28:10:
Rik schreef:
Haal je niet continu een nieuwe array / nieuwe objecten op omdat je $oSoapClient->getTransactions($aFilter) telkens opnieuw uitvoert?

Ik zou eerst de gettransactions in een var zetten, en vanuit daar verder gaan debuggen:
[COLOR= #0000BB]<?
    $tempVar[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$oSoapClient[/COLOR][COLOR= #007700]->[/COLOR]getTransactions[COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFilter[/COLOR][COLOR= #007700]);[/COLOR]

    [URL="http://www.php.net/var_dump"]var_dump[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tempVar[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// Krijgen we hier de verwachte output; krijgen we een object terug ?[/COLOR]

    [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$tempVar[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]) {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$transaction[/COLOR][COLOR= #007700]->[/COLOR]commission[COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Indien het een object is werkt dit. Anders moet je bijvoorbeeld met een arraynotatie werken. [/COLOR]
    [COLOR= #007700]}[/COLOR]
?>


Volgens mij krijg je namelijk een array terug, geen object. Dan zou je dus $transaction[commission] moeten doen.

Er komt inderdaad een array terug uit de var_dump.
De foreach werkt niet.
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Remcoboy schreef:
Er komt inderdaad een array terug uit de var_dump.
De foreach werkt niet.
Je kreeg dus dit:

object(stdClass)#43 (5) {
  ["totalResults"]=>
  int(38)
  ["startOffset"]=>
  int(1)
  ["endOffset"]=>
  int(38)
  ["requestTime"]=>
  int(1)
  ["message"]=>
  NULL
}


En je wilt daar commission uit halen? Ik zie dat nergens staat hoor, krijg je inderdaad niks.
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommity schreef:
Eerdere citaten tonen
Remcoboy schreef:
Er komt inderdaad een array terug uit de var_dump.
De foreach werkt niet.

Je kreeg dus dit:

object(stdClass)#43 (5) {
  ["totalResults"]=>
  int(38)
  ["startOffset"]=>
  int(1)
  ["endOffset"]=>
  int(38)
  ["requestTime"]=>
  int(1)
  ["message"]=>
  NULL
}


En je wilt daar commission uit halen? Ik zie dat nergens staat hoor, krijg je inderdaad niks.
Nee, ik krijg deze array:
Spoiler tonen
array(2) {
  ["return"]=>
  array(20) {
    [0]=>
    object(stdClass)#23 (32) {
      ["affiliatemarketing_id"]=>
      string(18) "code"
      ["date_transaction"]=>
      string(25) "2013-02-15T10:33:28+01:00"
      ["date_click"]=>
      string(25) "2013-02-15T10:32:20+01:00"
      ["media_id"]=>
      int(148000)
      ["media_name"]=>
      string(18) "Tips voor besparen"
      ["program_id"]=>
      int(6030)
      ["program_name"]=>
      string(18) "NAAM"
      ["adgroup_id"]=>
      int(50540)
      ["ad_id"]=>
      int(1281370)
      ["fourhash"]=>
      string(32) "code"
      ["commision"]=>
      float(1)
      ["currency"]=>
      string(3) "EUR"
      ["sub_id"]=>
      NULL
      ["description"]=>
      string(18) "NAAM"
      ["ip"]=>
      string(11) "0.87.XXX.58"
      ["referer"]=>
      string(0) ""
      ["status"]=>
      string(4) "open"
      ["disapprove_reason"]=>
      NULL
      ["approval_date"]=>
      NULL
      ["last_modified"]=>
      string(25) "2013-04-22T07:32:38+02:00"
      ["referencenumber"]=>
      NULL
      ["country_id"]=>
      int(121)
      ["country_code"]=>
      string(2) "nl"
      ["province"]=>
      array(0) {
      }
      ["gender"]=>
      array(0) {
      }
      ["age_category"]=>
      NULL
      ["revenue"]=>
      NULL
      ["extra1"]=>
      NULL
      ["extra2"]=>
      NULL
      ["extra3"]=>
      NULL
      ["extra4"]=>
      NULL
      ["extra5"]=>
      NULL
    }
    [1]=>
    object(stdClass)#24 (32) {
....
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wacht ff, die code die je hierboven gaf, kreeg je die uit Riks code of je eigen met var_dump?
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
Wacht ff, die code die je hierboven gaf, kreeg je die uit Riks code of je eigen met var_dump?
De array uit Riks code en mijn topicstart

De
object(stdClass)#43 (5) {


uit jouw code.
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Probeer eens $transaction["return"][0]["commission"]
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
Probeer eens $transaction["return"][0]["commission"]
Fatal error: Cannot use object of type stdClass as array
Spoiler tonen
$transaction = $oSoapClient->getTransactions($aFilter);
echo $transaction["return"][0]["commission"];
?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Gebruik het als object ( -> )
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren