Welcome to WebmasterWorld Guest from 54.167.185.18

Forum Moderators: httpwebwitch

Message Too Old, No Replies

XML problem

   
6:43 pm on Oct 17, 2010 (gmt 0)

10+ Year Member



I'm trying to do something that shouldn't be too hard but I'm struggling with it.

I need to send a request to an API and get the response. I've been on with this all weekend so any help is greatly appreciated.

This is the code I'm trying.

<?php

$password = 'passwordhere';
$productCode = 'ITEMCODEHERE';
$userName = 'USERNAMEHERE';

$xmlParameters = "password=$password&productCode=productCode";

$client = new SoapClient('https://api.domain.com/');

$res = $client->GetImagesforProduct($userName,$xmlParameters);

$contentString = $res->contentString;

print($contentString);

?>
7:34 pm on Oct 19, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



U forgot the "$" in front of "productCode"

try this:

$xmlParameters = "password=" . $password . "&productCode=" . $productCode;


I'll assume that $client is defined, has a method named "GetImagesforProduct", and returns an object with a child named "contentString". Otherwise there's not much to debug.

do you have error reporting turned on?
7:35 pm on Oct 19, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



you may also enjoy using this nifty built-in PHP function:

[php.net...]