Jump to content

unplugged_web

Members
  • Posts

    897
  • Joined

  • Last visited

Posts posted by unplugged_web

  1. If I remove the var_dump and change it so that it sends the login credentials as an array ( $result=$proxy->GetAddressBooks( array("username" => "username", "password" => "password") ); ) then I get this error:

    HTTP Error: no proper separation of headers and document
    If I get the results of $proxy then the top part is:
    object(nusoap_proxy_2105358451)#8 (52) { ["username"]=> string(0) "" ["password"]=> string(0) "" ["authtype"]=> string(0) "" ["certRequest"]=> array(0) { } ["requestHeaders"]=> bool(false) ["responseHeaders"]=> string(0) "" ["responseHeader"]=> NULL ["document"]=> string(0) "" ["endpoint"]=> string(35) "https://apiconnector.com/v2/Api.svc" ["forceEndpoint"]=> string(0) "" ["proxyhost"]=> bool(false) ["proxyport"]=> bool(false) ["proxyusername"]=> bool(false) ["proxypassword"]=> bool(false) ["portName"]=> string(0) "" ["xml_encoding"]=> string(0) "" ["http_encoding"]=> bool(false) ["timeout"]=> int(0) ["response_timeout"]=> int(30) ["endpointType"]=> string(4) "wsdl" ["persistentConnection"]=> &bool(false) ["defaultRpcParams"]=> bool(false) ["request"]=> string(671) "POST /v2/Api.svc HTTP/1.0 Host: apiconnector.com User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "http://apiconnector.com/v2/ApiService/GetAddressBooks"

     

     

    Unfortunately the only documentation I've got is this: http://api.dotmailer.com/v2/api.svc#op.ApiService.GetAddressBooks which is for SOAP rather than NUSOAP
  2. I'm sorry I don't really understand what you mean. If I use var_dump on $result it outputs bool(false)
    while if I get a dump of $client then it looks like it outputs everything (I think it output everything from this page: https://apiconnector.com/v2/api.svc?wsdl). Although the first part of it is this:
    object(soapclient)#1 (50) { ["username"]=> string(0) "" ["password"]=> string(0) "" ["authtype"]=> string(0) "" ["certRequest"]=> array(0) { } ["requestHeaders"]=> bool(false) ["responseHeaders"]=> string(0) "" ["responseHeader"]=> NULL ["document"]=> string(0) "" ["endpoint"]=> string(40) "https://apiconnector.com/v2/api.svc?wsdl" ["forceEndpoint"]=> string(0) "" ["proxyhost"]=> bool(false) ["proxyport"]=> bool(false) ["proxyusername"]=> bool(false) ["proxypassword"]=> bool(false) ["portName"]=> string(0) "" ["xml_encoding"]=> string(0) "" ["http_encoding"]=> bool(false) ["timeout"]=> int(0) ["response_timeout"]=> int(30) ["endpointType"]=> string(4) "wsdl" ["persistentConnection"]=> &bool(false) ["defaultRpcParams"]=> bool(false) ["request"]=> string(0) "" ["response"]=> string(0) "" ["responseData"]=> string(0) "" ["cookies"]=> array(0) { } ["decode_utf8"]=> bool(true) ["operations"]=> array(109) {

     

    I'm not sure what to look for although I did try removing the values from the username and password fields and still got the same results. My thinking is that the username and password aren't being sent in this line - $result=$proxy->GetAddressBooks( $username,$password );

    I don't know how to correct that though :(

  3. Is there any debug output that it is showing?It looks like the documentation for Nusoap is included in the download package. I would check the documentation to look for properties you can use for debugging. Post #4 on this page lists a few of them:http://community.sitepoint.com/t/consuming-web-service-from-php-using-nusoap/4385/3

     

    There's around a 1mb file that I don't understand but at the bottom it says:

     

    2015-03-26 17:37:23.176334 soapclient: checkWSDL

    2015-03-26 17:37:23.176367 wsdl: getOperations for port '' bindingType http://schemas.xmlsoap.org/wsdl/soap/2015-03-26 17:37:23.176387 wsdl: getOperations checking port Secure_ApiService bindingType http://schemas.xmlsoap.org/wsdl/soap/2015-03-26 17:37:23.176404 wsdl: getOperations found port Secure_ApiService bindingType http://schemas.xmlsoap.org/wsdl/soap/2015-03-26 17:37:23.176478 soapclient: got 109 operations from wsdl https://apiconnector.com/v2/api.svc?wsdl for binding type soap Error Fault

     

  4. I'm trying to use a SOAP API with nusoap but am having some real problems with it. I've never used SOAP before (nor have I used NUSOAP either) and would be grateful for any help please.
    This is the page I'm using to help me: http://api.dotmailer.com/v2/api.svc#op.ApiService.GetAddressBooks and this is what I'm using this to get the results:
    <?php    # initialise    $username='username@apiconnector.com';    $password='password';    $error_message1="Something went wrong with client ";    $error_message2="Something went wrong with proxy ";    $error_message3="Something went wrong with result 1st ";    $error_message4="Something went wrong with result 2nd ";    $error_message5="Something went wrong with result 3rd ";    $wsdlPath = "https://apiconnector.com/v2/api.svc?wsdl";    # perform lookup      require $INSTALL['include']."/nusoap/lib/nusoap.php";      $client=new soapclient( $wsdlPath,'wsdl' );      $err=$client->getError();      if( $err ) { echo $error_message1; exit( $err ); }            # create a proxy client.      $proxy=$client->getproxy();      $err=$proxy->getError();      if( $err ) { echo $error_message2; exit( $err ); }            # call the SOAP method for GetAddressBooks.      $result=$proxy->GetAddressBooks( $username,$password );      if( $proxy->fault ) {        echo $error_message3;      } else {        $err=$proxy->getError();        if( $err ) {          echo $error_message4; exit( $err );        } else {          if( $result['error_code']!='0' ){            echo $error_message5; exit( $err );          }          GetAddressBooksResult( $result );        }      } ?>
    That just outputs this Something went wrong with result 2nd wsdl error: phpType is struct, but value is not an array: see debug output for details.
    From the output I can see that the problem is here if( $err ) {

     

    echo $error_message4; exit( $err ); but I don't know how to fix that.
    I've also checked the debug log and says this:
    PHP Warning: Attempt to modify property of non-object in /ha/ha0/www/include/lib/nusoap.php on line 4694
    Line 4694 is:
    $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
  5. That's here:

    <script type="text/javascript">    $(".player").flowplayer();    var fp=$(".player").data("flowplayer");    $("#fullscreen").click(function(){ if( !fp.playing && !fp.loading ) { fp.load(); } fp.fullscreen(); });  </script>
  6. I'm trying without much success to get flow player to work on a test website. I have it working on another site but on the test site it just doesn't work. I get an error saying ReferenceError: Can't find variable: fp. The full error is:

    [Error] ReferenceError: Can't find variable: fp
    onOpen (player.php, line 447)
    p (jquery.bpopup-0.8.0.min.js, line 6)
    (anonymous function) (jquery.bpopup-0.8.0.min.js, line 6)
    each (jquery-1.10.2.min.js, line 4)
    each (jquery-1.10.2.min.js, line 4)
    bPopup (jquery.bpopup-0.8.0.min.js, line 6)
    (anonymous function) (player.php, line 442)
    dispatch (jquery-1.10.2.min.js, line 5)
    handle (jquery-1.10.2.min.js, line 5)

     

     

    Line 447 in the player.php is fp.load();
    The code I'm using to load the video (when somebody clicks a button is should load) is:
    $(".thumb-vid").click(function(){              $("#pop").bPopup({                modalClose: true, opacity: 0.6, positionStyle: 'fixed', onClose: function(e){                  if (fp.loading) { e.preventDefault(); }                  else { fp.unload(); }                }, onOpen: function(){                  fp.load();                }              });
    I'd be grateful for any help on this please, I've tried the flow player forum but they said they couldn't help because I'm not trying to get it to work on one of their pages.
    I also tried using console.log ('fp'); but that didn't show anything at all :(
  7. I'm trying to set up PayPal's Express Checkout on a custom built shopping cart but I've never done anything like this before and didn't know if anybody had dine this before?

    I've followed PayPal's instructions but when I add the code to the page that handles the billing I just get an error saying:
    Direct credit card payment API call failed. Detailed Error Message: OrderTotal (Amt) : Required parameter missingShort Error Message: Missing ParameterError Code: 81100Error Severity Code: Error
    I tried adding the code to the page where they click to pay with PP as well as on it's own page but I get the same error both times. I know I'm doing something wrong but am not sure exactly what and would be grateful for any help please
    Thanks
  8. If the example that they post doesn't work then you might want to contact them to let them know and ask why. Maybe their WSDL file is incorrect.

     

     

    So it's not necessarily me being dumb it may be their file. I'll contact them about it now

     

    Thanks

  9. I tried using their code but that gave the same error but for the ListAddressBooks method:

    PHP Fatal error: Call to undefined method soapclient::ListAddressBooks()

    Even if I try it with login instead of username it still fails.

    I've also double checked the credentials and they correct

  10. According to the PHP manual the option isn't "username", it's "login". The SoapClient class doesn't have an option called "addressBookId". This is setting up the general SOAP client, not using the specific API. You would send the address book ID with the call to the next method, not when creating the SOAP client.

     

    I was following the instructions from dot mailers website: https://support.dotmailer.com/entries/20668943-Accessing-the-API-using-PHP but will try it with login rather than username and remove the addressBookId.
    One question though, the error log says that the problem is on this line: $result = $client->GetContactsInAddressBook(array('withFullData')); which is after the username/login line, does that not mean that username is okay or have I misread the error?
    EDIT: I tried login instead of username and that gave the same "PHP Fatal error: Call to undefined method soap client::GetContactsInAddressBook() error."
  11. If you need to authenticate with the soap service then you need to password the login and password options to the constructor when you create the new object. There are several examples of using the options here:http://php.net/manual/en/soapclient.soapclient.php

    I changed that but am still getting the same PHP Fatal error: Call to undefined method soapclient::GetContactsInAddressBook() error. The code I'm using is:

    <?php$client = new SoapClient("https://apiconnector.com/v2/api.svc?wsdl", array("username" => "xxxxxxxxxx", "password" => "xxxxxxxxxx", "addressBookId" => "xxxxxxxxxx"));$result = $client->GetContactsInAddressBook(array('withFullData'));$array = $result->GetContactsInAddressBook->GetContacts;print "<table border='2'><tr><th></th><th>addressBookId</th><th>withFullData</th></tr>";foreach($array as $k=>$v){print "<tr><td align='right'>" . ($k+1) . "</td><td>" . $v->addressBookId . "</td><td align='right'>" . $v->withFullData . "</td></tr>";}print "</table>";?>

     

    I really don't know what I'm doing wrong here as I've followed help/tutorials and read about it but it's still not working :(

  12. I've tried to read up about SOAP API's and have now changed it to this:

    <?php$client = new SoapClient("https://apiconnector.com/v2/api.svc?wsdl");$params = array("username" => "username", "password" => "password");$result = $client->GetContactsInAddressBook(array('withFullData'=>5));$array = $result->GetContactsInAddressBook->GetContacts;print "<table border='2'><tr><th></th><th>addressBookId</th><th>withFullData</th></tr>";foreach($array as $k=>$v){print "<tr><td align='right'>" . ($k+1) . "</td><td>" . $v->addressBookId . "</td><td align='right'>" . $v->withFullData . "</td></tr>";}print "</table>";?>

    but I'm still not getting anything. I've checked the error log an it says this

     

    Call to undefined method soapclient::GetContactsInAddressBook()
    but I don't understand as it looks like that's what it says it should be?
  13. URL-encoding will convert the equal sign to its numeric entity. You are base64-encoding, you are not URL-encoding. URL-encode the base64 value, which will be padded with equal signs if necessary.

    I've now URL encoded the signature but I'm still getting a SignatureDoesNotMatch error. Ive to this for the for action and method:

     

    <form action="https://payments-sandbox.amazon.co.uk/cba/api/purchasecontract/?AWSAccessKeyId=AWS_ACCESS_KEY&Action=SetPurchaseItems&PurchaseContractId=amzn1.contract.1.1.2.5a49fd0d6fab162cdd34dc868c8735db&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=<?php echo gmdate("Y-m-dTH:i:s", time()); ?>&Version=2010-08-31&Signature=<?php echo urlencode(hash_hmac('SHA256','AWS_SECRET_KEY','secret')); ?>" method="post">
  14. I've followed that an changed the code to this
    <form action="https://payments-sandbox.amazon.co.uk/cba/api/purchasecontract/?AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=SetPurchaseItems&PurchaseContractId=amzn1.contract.1.1.1.e51e9a391b97ad59eabe0ab82a9370bc&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=<2014-11-04T10:25:53&Version=2010-08-31&Signature=<?php echo base64_encode(hash_hmac('SHA256','AWS_SECRET_KEY','secret')); ?>" method="post">........</form>
    but now get this error:
    AWSAccessKeyId= AWS_ACCESS_KEY_ID&Action=SetPurchaseItems&PurchaseContractId=amzn1.contract.1.1.1.e51e9a391b97ad59eabe0ab82a9370bc&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-11-12T16:31:19&Version=2010-08-31&Signature=NWI5MWI1NWI0MzkzODAwMTlkOTFlOGI1ODAwMGYxYTk1MWZmZGQ3ZDA4M2IzMTI2Y2Y5YmU4ZmUxOGU2YTllYQ==&PurchaseItems.PurchaseItem.1.FulfillmentNetwork=MERCHANT&PurchaseItems.PurchaseItem.1.MerchantId=A2PBOQNHNISJLT&PurchaseItems.PurchaseItem.1.MerchantItemId=344&PurchaseItems.PurchaseItem.1.Title=Lemon+500g+sample&PurchaseItems.PurchaseItem.1.Quantity=2&PurchaseItems.PurchaseItem.1.UnitPrice.Amount=10.79&PurchaseItems.PurchaseItem.1.UnitPrice.CurrencyCode=GBP&DeliveryMethod.ServiceLevel=None&DeliveryMethod.DisplayableShippingLabel=11.99%3D%3D20%3D%3D3&Shipping.Amount=11.99&Shipping.CurrencyCode=GBP is not valid; the value of a query string parameter may not contain a '=' delimiter

     

    I think the problem is with the Signature as it's adding two '=' to it. but if I remove them both then the error says the signature doesn't match. I'm sure I'm missing the obvious but I'm so stuck with this.
  15. You're linking to the REST API, not the SOAP API. The WSDL for the SOAP API is here:https://api.dotmailer.com/v2/api.svc?wsdl

     

    • I've followed this as best as I can: https://api.dotmailer.com/v2/api.svc#op.ApiService.GetContactsInAddressBook and have now changed the code to this:
    • <?php$client = new SoapClient("http://apiconnector.com/v2/ApiService/GetContactsInAddressBook");$params = array("username" => "*******", "password" => "*******", "addressBookId" => "160189");$result = $client->GetContactsInAddressBook($params);var_dump($result);echo "done";?>
    • but again that gives an error about the 'GetContactsInAddressBook'. If I replace that line with
      $result = $client;
      I get an output that doesn't give me the data I need

  16. I've never worked with SOAP before so am not exactly sure how to display the results from this:

    <?php$client = new SoapClient("https://api.massmailer.com/v2/address-books/{AddressBookId}/contacts?withFullData={withFullData}");$params = array("username" => "USERNAME", "password" => "PASSWORD");$result = $client->GetAddressBookContacts($params);var_dump($result);echo "done";?>

    If I go to the page this is on nothing is rendered at all. Even the var_dump() is empty, but if I go to https://api.massmailer.com/v2/address-books/{AddressBookId}/contacts?withFullData={withFullData} I'm prompted to enter the API username and password then it displays everything.

    Ideally I'd like to get everything from the address book.

  17. I don't know what parameters they expect for the request you're trying to send. That list contains some of the same ones I see in the PDF. It's not sorted by the parameter name though, they want it to be sorted for the signature. Page 11 of the original PDF shows a more detailed version of the steps they want you to take to create the signature.

    Thanks, I'm probably just being really dumb and not reading it properly, I don't understand these two lines:

     

    3. Calculate an RFC 2104-compliant HMAC with the string you just created, your Secret Access Key as the key, and SHA256 or SHA1 as the hash algorithm.

    4. Convert the resulting value to base64.
For example, 5nB7nu7PFbCiDg+vYyWMj1JzEH3S+IzFoVgwHGjG5Ms=
  18. Sorry to be so dumb but what parameters do they want? Whenever I enter them manually and then test the button I get the InvalidSignature error message.

     

    I thought I had the right details:

     

    Action=SetPurchaseItem

    SignatureMethod=HmacSHA256
    PurchaseContractId=amzn1.contract.1.1.2.b9173045932801221f107a83429e5a69
    AWSAccessKeyId=AWS_ACCESS_KEY_ID
    SignatureSignate=SECRET_ACCESS_KEY
    SignatureVersion=2
    Version=2010-08-31
    Timestamp=2010-08-31T11:45:50.582Z
    I've also just found that this is the newest reference guide: http://amazonpayments.s3.amazonaws.com/documents/Inline_Checkout_API_Reference_Guide_UK.pdf
  19. Canonicalized is similar to standardized. The bullet points under that first item tell you how to build the canonical query string. They basically just want the parameters sorted and encoded.

    I'm sorry but I still don't understand? What do I do with the parameters, do I just save them or send them to Amazon?

     

    I tried pasting this into the browser:

    but all I got was <b><UnknownOperationException/></b>
    I also tried using Amazon's scratchpad but it didn't have any options for 'payments', 'purchase contract' or 'SetPurchaseItems'
    If it helps the full code for sending the order to amazon is:
    <form action="https://payments.amazon.co.uk/cba/api/purchasecontract/" method="get"><input type="hidden" name="Action" value="SetPurchaseItems" /><input type="hidden" name="AWSAccessKeyId" value="SAMPLE" /><input type="hidden" name="PurchaseContractId" value="<?php echo $_GET['purchaseContractId']; ?>" /><?php foreach( $order_line as $key=>$value ) { ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.FulfillmentNetwork" value="MERCHANT" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantId" value="SAMPLE" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantItemId" value="<?php echo $products_all[$value['product_id']]['id'] ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.Quantity" value="<?php echo $value['product_qty'] ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.Title" value="<?php echo htmldisplay( $products_all[$value['product_id']]['name'] ) ?>" /><?php if( count( $value['detail'] ) ) { ?><?php if( is_array( $product_detail ) ) { foreach( $product_detail as $key2=>$value2 ) { if( isset( $value['detail'][$key2] ) ) { ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.Description" value="Option: <?php echo htmldisplay( $value2['name'] ) ?>" /><?php } } ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.Amount" value="<?php if( $value['price_total']<0.01 ) { echo "00.00"; } else { echo (number_format( $value['price_total']/$value['product_qty']*$companydetails['exchange'],2 )); } ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.CurrencyCode" value="<?php echo htmldisplay( $companydetails['currency_iso']); ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.URL" value="product/<?php echo $products_all[$value['product_id']]['linkword'] ?>" /><?php } } } ?><input type="hidden" name="SignatureSignature" value="SAMPLE" /><input type="hidden" name="SignatureMethod" value="METHOD" /><input type="hidden" name="SignatureVersion" value="SIGNATUREVERSION" />
    <input type="hidden" name="Timestamp" value="<?php echo gmdate("Y-m-dTH:i:s.000Z", time()); ?>" />
    <input type="hidden" name="Version" value="VERSION" /> <input type="submit" class="input_button input_red" value="Complete order" /> </form>

    If I try to send that to Amazon the next page says this:

     

    <ErrorResponse xmlns="http://payments.amazon.com/checkout/v2/2010-08-31/">

    <Error>
    <Type>Sender</Type>
    <Code>IncompleteSignature</Code>
    <Message>
    Request must contain a signature that conforms to AWS standards
    </Message>
    </Error>
    <RequestId>996fbf92-640c-11e4-8312-a14373064631</RequestId>
    </ErrorResponse>
  20. I'm trying to add 'Checkout With Amazon' to our website and have got to the section where I need to create a signature but I'm not sure how to do this.

    It says I need a canonicalized query string, what does that mean? I've been trying to follow page 10 (Create the Signature) of this document
    I'd be really grateful for any help please.
×
×
  • Create New...