Trouble Using eBay Shopping API with PHP (GetSingleItem Request) - php

I have read over the documentation many times and tried solutions that I found on the internet and I am struggling to retrieve the data I want from the eBay Shopping API using the GetSingleItem request. I believe I have my headers and xml request set up correctly based on the examples in the documentation but I can't work out how to actually send the request and retrieve the xml response. Can someone help me on the next step please?
How do I actually send the request and retrieve the response?
My headers and xml request look like this:
// Create headers
$headers = array
(
'X-EBAY-API-APP-ID: ' . $app_id,
'X-EBAY-API-SITE-ID: ' . $site_id,
'X-EBAY-API-CALL-NAME: ' . $call_name,
'X-EBAY-API-VERSION: ' . $version,
'X-EBAY-API-REQUEST-ENCODING: ' . $encoding,
);
// Generate XML request
$xml_request = '<?xml version="1.0" encoding="utf-8"?>\n';
$xml_request .= '<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n';
$xml_request .= '<ItemID>283814879195</ItemID>\n';
$xml_request .= '<IncludeSelector>Details</IncludeSelector>\n';
$xml_request .= '</GetSingleItemRequest>';
What is the next step?
If it helps, this is my complete code so far that I have tried but I get "Failed to load" when I try to use simplexml_load_string. I have removed my app_id for security also:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
function getItem($itemID) {
$endpoint = 'https://open.api.ebay.com/shopping';
$app_id = 'XXXXXXXXXXX';
$site_id = '3';
$call_name = 'GetSingleItem';
$version = '863';
$encoding = 'xml';
// Create headers to send with CURL request.
$headers = array
(
'X-EBAY-API-APP-ID: ' . $app_id,
'X-EBAY-API-SITE-ID: ' . $site_id,
'X-EBAY-API-CALL-NAME: ' . $call_name,
'X-EBAY-API-VERSION: ' . $version,
'X-EBAY-API-REQUEST-ENCODING: ' . $encoding,
);
// Generate XML request
$xml_request = '<?xml version="1.0" encoding="utf-8"?>\n';
$xml_request .= '<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n';
$xml_request .= '<ItemID>283814879195</ItemID>\n';
$xml_request .= '<IncludeSelector>Details</IncludeSelector>\n';
$xml_request .= '</GetSingleItemRequest>';
$session = curl_init($endpoint); // create a curl session
curl_setopt($session, CURLOPT_POST, true); // POST request type
curl_setopt($session, CURLOPT_HTTPHEADER, $headers); // set headers using $headers array
curl_setopt($session, CURLOPT_POSTFIELDS, $xml_request); // set the body of the POST
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // return values as a string, not to std out
$responsexml = curl_exec($session); // send the request
curl_close($session); // close the session
return $responsexml; // returns a string
}
$itemID = '283814879195';
$resp = simplexml_load_string(getItem($itemID)) or die("Failed to load");
print($resp->Item->ItemID);
?>

I was having the same issue.
I'll be posting my project on my Github publicly once I am done, so here you go.
Note that ItemID is being passed into the function. You can ignore the GET in the first bit of code if you intend on hard coding the itemID.
$ItemID = $_GET['itemid'];
itemDetails($ItemID);
Then
function itemDetails($ItemID) {
$url = 'https://open.api.ebay.com/shopping';
$app_id = '[ADD YOUR APP ID]';
$site_id = '0';
$call_name = 'GetSingleItem';
$version = '863';
$encoding = 'xml';
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$xml.= "<GetSingleItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">";
$xml .= "<ItemID>".$ItemID."</ItemID>";
$xml .= "</GetSingleItemRequest>";
$headers = array(
'X-EBAY-API-APP-ID:'.$app_id,
'X-EBAY-API-SITE-ID:'.$site_id,
'X-EBAY-API-CALL-NAME:'.$call_name,
'X-EBAY-API-VERSION:'.$version,
'X-EBAY-API-REQUEST-ENCODING:'.$encoding,
'Content-type:text/xml;charset=utf-8'
);
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $url);
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $xml);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($connection);
echo $result;
curl_close($connection);
}
Hopefully, this helps!

Related

Workflow Max add job via API

I'm trying to add a job to the Workflow Max API. I seem to be hitting the API but I keep getting the error message:
Message not in expected format. The following required element was missing - Job/ClientID
I'm sure that the client ID is added but something seems to be wrong. This is the code:
function post_job_to_workflow_max($job_data) {
// configure our connection to the api
$api_token = 'API_KEY';
$acc_key = 'ACC_TOKEN';
$url = 'https://api.workflowmax.com/job.api/add?apiKey=' . $api_token . '&accountKey=' . $acc_key;
// Job data must match the format required by WorkflowMax
// currently accepts XML data
// see: https://www.workflowmax.com/api/job-methods#POST%20add
$xml = new SimpleXMLElement("<Job></Job>");
$xml->addChild('Name', $job_data[0]);
$xml->addChild('Description', $job_data[1]);
$xml->addChild('ClientID', 18754031);
// $clientID = $xml->addChild('Client');
// $clientID->addChild('ID', 18754031);
// $clientID->addChild('Name', "TEST CLIENT");
$xml->addChild('State', 'Planned');
$xml->addChild('StartDate', $job_data[2]);
$xml->addChild('DueDate', $job_data[3]);
// print_r($xml);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml',
'Content-Length: ' . strlen($xml->asXML()))
);
$output = curl_exec($ch);
curl_close($ch);
$result = simplexml_load_string($output);
print_r($result);
}
If there's anyone with experience of using WFM, would be good to hear how you approached it.
Thanks
So in answer to my own question, I did finally work this out.
The way I did this was to return the ID of the client from the function I used to post a client to WorkFlow Max. See code:
1) post the client
function post_client_to_workflowmax($client_data) {
// configure our connection to the api
$api_token = 'YOUR_TOKEN';
$acc_key = 'YOUR_KEY';
$url = 'https://api.workflowmax.com/client.api/add?apiKey=' . $api_token . '&accountKey=' . $acc_key;
// Client data must match the format required by WorkflowMax
// currently accepts XML data
// These indexes match up with how the data has been stored
// see: https://www.workflowmax.com/api/client-methods#POST%20add
$xml = new SimpleXMLElement("<Client></Client>");
$xml->addChild('Name', htmlspecialchars($client_data[2]));
$xml->addChild('Email', htmlspecialchars($client_data[9]));
$xml->addChild('Phone', htmlspecialchars($client_data[10]));
$xml->addChild('Address', htmlspecialchars($client_data[3]) . ' ' . htmlspecialchars($client_data[4]));
$xml->addChild('City', htmlspecialchars($client_data[5]));
$xml->addChild('Postcode', htmlspecialchars($client_data[7]));
$xml->addChild('Country', htmlspecialchars($client_data[8]));
$xml->addChild('IsProspect', 'No');
$contacts = $xml->addChild('Contacts');
$contact = $contacts->addChild('Contact');
$name = $contact->addChild('Name', htmlspecialchars($client_data[0]) . ' ' . htmlspecialchars($client_data[1]));
// POST request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml',
'Content-Length: ' . strlen($xml->asXML()))
);
$output = curl_exec($ch);
curl_close($ch);
// Create an array from the data that is sent back from the API
$result = simplexml_load_string($output);
$clientID = NULL;
// here we get the ID created for this client and pass it into the variable $clientID
foreach($result->Client as $k => $v) {
$clientID = $v->ID;
}
return $clientID;
}
We then get that ID passed into our job posting function like so:
2) post a job to WFM
function post_job_to_workflow_max($job_data, $clientID) {
// configure our connection to the api
$api_token = 'YOUR_TOKEN';
$acc_key = 'YOUR_KEY';
$url = 'https://api.workflowmax.com/job.api/add?apiKey=' . $api_token . '&accountKey=' . $acc_key;
// Job data must match the format required by WorkflowMax
// currently accepts XML data
// see: https://www.workflowmax.com/api/job-methods#POST%20add
$xml = new SimpleXMLElement("<Job></Job>");
$xml->addChild('ClientID', $clientID);
$xml->addChild('Name', htmlspecialchars($job_data[0]));
$xml->addChild('Description', htmlspecialchars($job_data[1]));
$xml->addChild('State', 'Planned');
$xml->addChild('StartDate', htmlspecialchars($job_data[2]));
$xml->addChild('DueDate', htmlspecialchars($job_data[3]));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml',
'Content-Length: ' . strlen($xml->asXML()))
);
$output = curl_exec($ch);
curl_close($ch);
$result = simplexml_load_string($output);
}
And then calling these functions looks something like this:
$id = post_client_to_workflowmax($client);
post_job_to_workflow_max($job, $id);
Where $client must be an array of data. This worked for my case but might not work for your particular case so you may need to edit the fields etc.
Hopefully this helps someone who is stuck with the same problem. Not the most elegant code but it gets the job done.

finditemsinebaystores returns items not for my store

I send a request xml to find items in my store that has any custom labels set for the seller. But ebay returns a response with a lot of items that not are in my store.
How can I do that?
That's my code:
$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';
self::get_cvs_array();
$xmlrequest;
$xml_filters = "";
$a = 1;
while ($a < count($this->cvs_array)) {
$xml_filters .="<itemFilter>\n<name>Custom Label</name>\n<value>".$this->cvs_array[$a][0]."</value>\n</itemFilter>\n";
$a += 1;
}
// Create the XML request to be POSTed
$xmlrequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$xmlrequest .= "<findItemsIneBayStoresRequest xmlns=\"http://www.ebay.com/marketplace/search/v1/services\">\n";
$xmlrequest .= "<storeName>myStoreName</storeName>\n";
$xmlrequest .= $xml_filters;
$xmlrequest .= "</findItemsIneBayStoresRequest>";
// Set up the HTTP headers
$headers = array(
'X-EBAY-SOA-SERVICE-NAME: FindingService',
'X-EBAY-SOA-OPERATION-NAME: findItemsIneBayStores',
'X-EBAY-SOA-SERVICE-VERSION: 1.3.0',
'X-EBAY-SOA-REQUEST-DATA-FORMAT: XML',
'X-EBAY-SOA-GLOBAL-ID: EBAY-ES',
'X-EBAY-SOA-SECURITY-APPNAME: $myAppId',
'Content-Type: text/xml;charset=utf-8',
);
$session = curl_init($endpoint); // create a curl session
curl_setopt($session, CURLOPT_POST, true); // POST request type
curl_setopt($session, CURLOPT_HTTPHEADER, $headers); // set headers using $headers array
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlrequest); // set the body of the POST
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // return values as a string, not to std out
$responsexml = curl_exec($session); // send the request
curl_close($session);
The findItemsIneBayStores is for finding items from sellers that have stores.
To get your own items, you should use GetMyeBaySelling instead.
In this call, you can use
<ActiveList>
<Include>true</Include>
</ActiveList>
to get only your Active List (will not include the Sold, Unsold, etc.).
You will find all the documentation needed here

API Integration for ProductSync in volusion

Here is the method provide by Volusion support for ProductSync but the code in C# i want to implement in PHP but how to implement it i don't know.
https://support.volusion.com/hc/en-us/articles/209637767-API-Integration-ProductSync-Developer-
So anyone can help me that how to implement in PHP because i am working on PHP i have no knowledge of C#. I just copy this code in paste in my PHP it give me an error like this
Fatal error: Class 'XMLHTTP' not found in /home/tlztech/public_html/volusion/productSync.php on line 5.
And my code as under.
<?php
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&API_Name=Generic\\Products&SELECT_Columns=p.ProductCode,p.ProductID,p.ProductName,p.StockStatus";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.send(null);
$api_response = $xml_http.responseText;
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&Import=Update";
$api_request = "";
$api_request = $api_request + "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$api_request = $api_request + "<xmldata>";
$api_request = $api_request + " <Products>";
$api_request = $api_request + " <ProductCode>0001</ProductCode>";
$api_request = $api_request + " <StockStatus>5</StockStatus>";
$api_request = $api_request + " </Products>";
$api_request = $api_request + "</xmldata>";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
$xml_http.setRequestHeader("Content-Action", "Volusion_API");
$xml_http.send(api_request);
$xml_http = $xml_http.responseText;
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&API_Name=Generic\\Products&SELECT_Columns=p.ProductCode,p.ProductID,p.ProductName,p.StockStatus&WHERE_Column=p.ProductCode&WHERE_Value=0002";
$xml_http = new XMLHTTP();
$xml_http.open("POST", $api_url, false, "", "");
$xml_http.send(null);
$api_response = $xml_http.responseText;
?>
You're trying to reference a Microsoft class that doesn't exist in PHP.
I see in your other recent threads that you've tried to call the Volusion API with cURL. This is a valid approach that I use with PHP. There's no need to adapt the C# example into PHP.
Here is a valid example in PHP using cURL and your URL example:
$api_url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspx?Login=mylogin&EncryptedPassword=mypass&Import=Update";
$api_request = '<?xml version="1.0" encoding="utf-8" ?>';
$api_request .= '<xmldata>';
$api_request .= ' <Products>';
$api_request .= ' <ProductCode>0001</ProductCode>';
$api_request .= ' <StockStatus>5</StockStatus>';
$api_request .= ' </Products>';
$api_request .= '</xmldata>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_request);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
$head = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
I think it's because you need to use namespace of you're XMLHTTP class :
$xml_http = new Your\Namespace\XMLHTTP();
because there is no XMLHTTP class in your file. That's why it is not found
Then if you want to use only XMLHTTP() you need to add a use at the beginning of your file:
use <NAMESPACE>;
If this class is from the global namespace just do it like that :
$xml_http = new \XMLHTTP();

ebay api - send xml request via php

Can anyone see what I'm missing? I keep getting no response, The xml file is correct, so are the headers and url but I'm not getting anything in response.
<?php
error_reporting(E_ALL);
$URL = $_REQUEST['URL'];
$site = $_REQUEST['site'];
$file = fopen($URL, 'r');
$xmlRequest = fread($file, filesize($URL));
echo "<textarea>" . $xmlRequest . "</textarea>"; //this is me making sure the file
//actually contains the xml doc
$endpoint = "https://api.sandbox.ebay.com/ws/api.dll";
$session = curl_init($endpoint); // create a curl session
curl_setopt($session, CURLOPT_POST, true); // POST request type
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlRequest); // set the body of the POST
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // return values as a string - not to std out
$headers = array(
'X-EBAY-API-CALL-NAME: GetCategories',
'X-EBAY-API-SITE-ID: ' . $site,
'X-EBAY-API-DEV-NAME: *****',
'X-EBAY-API-APP-NAME: *****',
'X-EBAY-API-CERT-NAME: *****',
'X-EBAY-API-COMPATIBILITY-LEVEL: 761',
'X-EBAY-API-REQUEST-ENCODING: XML', // for a POST request, the response by default is in the same format as the request
'Content-Type: text/xml;charset=utf-8'
);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers); //set headers using the above array of headers
$responseXML = curl_exec($session); // send the request
curl_close($session);
if ($responseXML = '' OR $responseXML = ' ') {
echo "Failed!";
}
echo $responseXML;
return $responseXML; // returns a string
?>
Try this:
$xml_response = simplexml_load_string($responseXML);
Inside of this xml_response you must find Ack
$xml_response->Ack
the values can be : Warning, Failure or Success and gives you the type of error (if there was an error in the request)

Post form data to external url + curl

I have this form that I am trying to use to post data to an external url. I do have some very basic knowlegde of using php curl. So far if I use this code that I have written:
<?php
if ($_POST['request_callback'])
{
$customer_name = cleaninput($_REQUEST['customer_name'],"text");
$debtor_id = cleaninput($_REQUEST['debtor_id'],"number");
$telephone_number = cleaninput($_REQUEST['customer_number'],"number");
if ($_POST['callme_now'] == '1') {
$callback_time = date('y-m-d ' . $_POST['hour_select'] . ':' . $_POST['minute_select'] . ':s');
} else {
$callback_time = date('y-m-d H:i:s');
}
// Send using CURL
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "http://www.myjoomla.eo/test.php"); // URL to post
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "Name=$customer_name&Debtor_ID=$debtor_id&Telephone_Number=$telephone_number&CallBack_Time=$callback_time");
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec( $ch ); // runs the post
curl_close($ch);
echo "Reply Response: " . $result; // echo reply response
}
?>
So far, it does post to the file and the results are display. Now how do I format the data that has been posted into xml format? Ideally, I am trying to acheive something like this an xml that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<CallRequest>
<ProjectName>Test</ProjectName>
<ContactNumberToDial>07843088348</ContactNumberToDial>
<DateTimeToDial></DateTimeToDial>
<ListSource>WebLead</ListSource>
<AgentName></AgentName>
<AddToList>False</AddToList>
<SpecificAgent>False</SpecificAgent>
<DBField>
<FieldName>Name</FieldName>
<FieldValue>Testing</FieldValue>
</DBField>
</CallRequest>
Anyone have an Idea of what to do here?
Thanks,
James
An XML library I have used in the past that allows you to create XML using PHP is XmlWriter. This library was originally written to work with PHP4. You'll find that its name conflicts with that of a built-in PHP5 class so you'll need to change both the class declaration and the constructor to something else.
Hope that helps!
I agree with jkndrkn - it seems cURL is correct, it's a matter of the output from test.php. IBM has a great article about reading/writing/parsing XML with PHP, check it out here.
Hi Sorry for taking a while in getting back. Been trying to figure this out in a few way. What I have been told is that the client wants to post an xml string to the given URL. When looking at sample pages, they have got 3 examples of what could be then. There is an example with SOAP 1.1 which display the request and response, an example with SOAP 1.2 request and response, an HTTP GET request and response sample and an HTTP POST request and response sample.
I have opted for the latter which I feel will be the easiest to work with and I am using PHP curl.
The HTTP POST example is this:
Request:
POST /ClickToCall/CallRequest.asmx/Call HTTP/1.1
Host: 194.217.1.2
Content-Type: application/x-www-form-urlencoded
Content-Length: length
xmlString=string
Response:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
When I enter the xmlString manual on the url's test page, I get the necessary responses.
The xmlString looks like this:
<?xml version="1.0" encoding="utf-8"?><CallRequest><ProjectName>Noble Test</ProjectName><ContactNumberToDial>07843088348</ContactNumberToDial><DateTimeToDial>2009-12-10 18:30:53</DateTimeToDial><ListSource>WebLead</ListSource><AgentName></AgentName><AddToList>False</AddToList><SpecificAgent>False</SpecificAgent><DBField><FieldName>Name</FieldName><FieldValue>NobleTesting</FieldValue></DBField></CallRequest>
When I use my code however, I get no response at all.
This is the code I am using:
<?php
if ($_POST['request_callback'])
{
$customer_name = cleaninput($_REQUEST['customer_name'],"text");
$debtor_id = cleaninput($_REQUEST['debtor_id'],"number");
$telephone_number = cleaninput($_REQUEST['customer_number'],"number");
if ($_POST['callme_now'] == '1') {
$callback_time = date('y-m-d ' . $_POST['hour_select'] . ':' . $_POST['minute_select'] . ':s');
} else {
$callback_time = date('y-m-d H:i:s');
}
// XML data as string
$request = '<?xml version="1.0" encoding="utf-8"?>';
$request .= '<CallRequest>';
$request .= '<ProjectName>Nobel Test</ProjectName>';
$request .= '<ContactNumberToDial>' . $telephone_number . '</ContactNumberToDial>';
if (isset($_POST['callme_now'])) {
$request .= '<DateTimeToDial></DateTimeToDial>';
} else {
$request .= '<DateTimeToDial>' . date('Y-m-d ' . $_POST['hour_select'] . ':' . $_POST['minute_select'] . ':s') . '</DateTimeToDial>';
}
$request .= '<ListSource>WebLead</ListSource>';
$request .= '<AgentName></AgentName>';
$request .= '<AddToList>False</AddToList>';
$request .= '<SpecificAgent>False</SpecificAgent>';
$request .= '<DBField>';
$request .= '<FieldName>Customer Name</FieldName>';
$request .= '<FieldValue>' . $customer_name . '</FieldValue>';
$request .= '</DBField>';
$request .= '</CallRequest>';
// Create Headers
$header[] = "Host: www.myjoomla.eo";
$header[] = "Content-type: application/x-www-form-urlencoded";
$header[] = "Content-length: ". strlen($request) . "\r\n";
$header[] = $request;
$loginUsername = "username";
$loginPassword = "password";
// Send using CURL
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "http://194.217.1.2/ClickToCall/CallRequest.asmx/Call"); // URL to post
curl_setopt( $ch, CURLOPT_USERPWD, "$loginUsername:$loginPassword"); //login
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $header);
$result = curl_exec( $ch ); // runs the post
curl_close($ch);
echo "Reply Response: " . $result; // echo reply response
echo " ";
echo "";
print_r($header);
echo "";
// return $result;
}
Does anyone see anything with with the above code? Thanks

Categories