I'm trying to send data to a Web Server using my W5100 shield with Arduino. But for some reason I'm getting this problem when I try to send, It seems like an HTTP Error. I'm editing so you can see my Arduino code too, maybe it helps. I hope I will be able to send this data, I tried changing HTTP/1.0 to HTTP/1.1 but had no success.
The problem:
Connected to network, your ip: 192.168.100.00
Connecting to the server and sending data:
Sensor 1 = 7.00
Sensor 2 = 9.00
Sensor 3 = 89.00
HTTP/1.1 302 Found
Date: Wed, 16 Oct 2019 18:47:20 GMT
Server: Apache
Location: https://mywebsite.com.br/conexao.php?s1=7.00&s2=9.00&s3=89.00
Content-Length: 317
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache Server at mywebsite.com.br Port 80</address>
</body></html>
This is the Arduino code
if (ArduinoClient.available())
{
char dadosretornados = ArduinoClient.read();
Serial.print(dadosretornados);
}
if (!ArduinoClient.connected())
{
ArduinoClient.stop();
}
char comando = Serial.read();
if (comando == '1')
{
//====================================================== ENFEITE ============================================================================================================
Serial.println("\n");
Serial.println("Conectando ao servidor e enviando dados: ");
delay(500); //Delay apenas de enfeite
Serial.print("Sensor 1 = ");
Serial.println(sensor1);
Serial.print("Sensor 2 = ");
Serial.println(sensor2);
Serial.print("Sensor 3 = ");
Serial.println(sensor3);
delay(1000); //Delay apenas de enfeite
Serial.println("\n");
//===========================================================================================================================================================================
if (ArduinoClient.connect(servidor, 80))
{
//Sucesso ao conectar
//ArduinoClient.println("GET /conexao.php HTTP/1.0"); // Podemos trocar para HTTP/1.1 se der algum problema
ArduinoClient.print("GET /conexao.php?");
ArduinoClient.print("s1=");
ArduinoClient.print(sensor1);
ArduinoClient.print("&s2=");
ArduinoClient.print(sensor2);
ArduinoClient.print("&s3=");
ArduinoClient.print(sensor3);
ArduinoClient.println(" HTTP/1.0");
ArduinoClient.println("Host: mywebsite.com.br");
ArduinoClient.println("Connection: close");
ArduinoClient.println();
}
else
{
This is because your site is redirecting to https://. Don’t waste your time as Arduino doesn’t have enough processing power and memory to process complex SSL requests. I already wasted my many nights. Post to http:// or use ESP which has required libraries to processs https:// requests.
Trying to put an order via webservice. I've followed the correct order via webservice:
Create customer (customers blank schema)
Create customer's address (addresses blank schema)
Create associated customer's cart(carts blank schema)
Create Order (orders blank schema)
The problem is when order will be created and saved in database. I've launched the function which imports data into client + address + cart + order; aparently everything works fine, client, address and cart was created correctly, but not the order...
I've tested on php 5.6.30 server on my localhost lap and everything works fine but in a production php 5.5.9 server orders won't be created...
This is the function to create order:
$xml = $webService->get(array('url' => PS_SHOP_PATH .'api/orders/?schema=blank'));
$pedido = $xml->children()->children();
$direccion = getDireccion($idCliente, $webService);
$carrito = getCarrito($idCarrito, $webService);
$numProdPedido = count($carrito->associations->cart_rows->cart_row);
$pedido->id_address_delivery = $direccion['address']['id']; // Customer address
$pedido->id_address_invoice = $direccion['address']['id'];
$pedido->id_cart = $idCarrito;
$pedido->id_currency = $carrito->id_currency;
$pedido->id_lang = $carrito->id_lang;
$pedido->mp_order_id = $refPedido;
$pedido->reference = $refPedido;
$pedido->id_customer = $carrito->id_customer;
$pedido->id_carrier = $carrito->id_carrier;
$pedido->payment = $refPedido;//$pedido_ws['paymentType'];
$pedido->module = 'cashondelivery';
$pedido->total_paid = $pedido_ws['total_price'];
$pedido->total_paid_real = $pedido_ws['total_price'];
$pedido->total_products = $numProdPedido;
$pedido->total_products_wt = $numProdPedido;
$pedido->conversion_rate = 1;
// Others
$pedido->valid = '1';
$pedido->current_state = '1';
getEstadoPedido($pedido->order_state);
$pedido->total_discounts = $pedido_ws['promotions']['total_deduced_amount'];
$pedido->total_discounts_tax_incl = $pedido_ws['promotions']['total_deduced_amount'];
$pedido->total_discounts_tax_excl = $pedido_ws['promotions']['total_deduced_amount'];
$pedido->total_paid_tax_incl = $pedido_ws['total_price'];
$pedido->total_paid_tax_excl = $pedido_ws['total_price'];
$pedido->total_shipping = $pedido_ws['shipping_price'];
$pedido->total_shipping_tax_incl = $pedido_ws['shipping_price'];
$pedido->total_shipping_tax_excl = $pedido_ws['shipping_price'];
$ind = 0;
foreach($carrito->associations->cart_rows->cart_row as $producto){
$prod = getProductoById($producto->id_product, $webService);
$pedido->associations->order_rows->order_row[$ind]->product_id = $producto->id_product;
$pedido->associations->order_rows->order_row[$ind]->product_attribute_id = $producto->id_product_attribute;
$pedido->associations->order_rows->order_row[$ind]->product_quantity = $producto->quantity;
$pedido->associations->order_rows->order_row[$ind]->product_name = $prod->name->language[0];
$pedido->associations->order_rows->order_row[$ind]->product_reference = $prod->reference;
$pedido->associations->order_rows->order_row[$ind]->product_price = $prod->price;
$pedido->associations->order_rows->order_row[$ind]->unit_price_tax_incl = $prod->price;
$pedido->associations->order_rows->order_row[$ind]->unit_price_tax_excl = $prod->price;
$ind++;
}
// Creating the order
$opt = ['resource' => 'orders'];
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
Any clues?
Edit: XML request and response code when calling order webservice. This is the last order xml.
HTTP REQUEST HEADER
POST //api/orders HTTP/1.1
Authorization: Basic WDMxSlRJRjFTNTNIMVlTS0hZRUFHTjlJVk5CQ1ZHTlg6
Host: www.mywebsite.com
Accept: */*
Content-Length: 1956
Content-Type: application/x-www-form-urlencoded
HTTP RESPONSE HEADER
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 26 Apr 2017 10:08:06 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Authorization,Accept-Encoding
X-Powered-By: PHP/5.5.9-1ubuntu4.19
Set-Cookie: PrestaShop-300d307acc0ec8525a71119b0dd393d8=0XUqFuC%2BvHy%2B%2BAU8Uod5odM7En0QQlQNh2ZWuI7VO6wTSlgh%2F%2FlVEDyz4e%2BJUv55b3N6fHTdEz%2Fmyjob65wxqjofdRVglsNIauli6yfcEBQ%3D000079; expires=Tue, 16-May-2017 10:08:05 GMT; Max-Age=1727999; path=/; domain=www.mywebsite.com; httponly
XML SENT
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
<id/>
<id_address_delivery>31754</id_address_delivery>
<id_address_invoice>31754</id_address_invoice>
<id_cart>1314430</id_cart>
<id_currency>1</id_currency>
<id_lang>1</id_lang>
<id_customer>22578</id_customer>
<id_carrier>1</id_carrier>
<current_state>3</current_state>
<module>cashondelivery</module>
<invoice_number/>
<invoice_date/>
<delivery_number/>
<delivery_date/>
<valid>1</valid>
<date_add/>
<date_upd/>
<shipping_number/>
<id_shop_group/>
<id_shop/>
<secure_key/>
<payment>40862744-A</payment>
<recyclable/>
<gift/>
<gift_message/>
<mobile_theme/>
<total_discounts>0</total_discounts>
<total_discounts_tax_incl>0</total_discounts_tax_incl>
<total_discounts_tax_excl>0</total_discounts_tax_excl>
<total_paid>25.98</total_paid>
<total_paid_tax_incl>25.98</total_paid_tax_incl>
<total_paid_tax_excl>25.98</total_paid_tax_excl>
<total_paid_real>25.98</total_paid_real>
<total_products>1</total_products>
<total_products_wt>1</total_products_wt>
<total_shipping>2.99</total_shipping>
<total_shipping_tax_incl>2.99</total_shipping_tax_incl>
<total_shipping_tax_excl>2.99</total_shipping_tax_excl>
<carrier_tax_rate/>
<total_wrapping/>
<total_wrapping_tax_incl/>
<total_wrapping_tax_excl/>
<round_mode/>
<conversion_rate>1</conversion_rate>
<reference/>
<associations>
<order_rows>
<order_row>
<id/>
<product_id>233154</product_id>
<product_attribute_id>0</product_attribute_id>
<product_quantity>1</product_quantity>
<product_name>Smartwatch Gt08 Sim sd bluetooth Negro plata</product_name>
<product_reference>8435338885678</product_reference>
<product_ean13/>
<product_upc/>
<product_price>25.920000</product_price>
<unit_price_tax_incl>25.920000</unit_price_tax_incl>
<unit_price_tax_excl>25.920000</unit_price_tax_excl>
</order_row>
</order_rows>
</associations>
</order>
</prestashop>
RETURN HTTP BODY
**Here is blank space, don't know if there will be some response xml code...
Try setting these to an empty string. If that doesn't work try setting it to your product ID.
$xml->order->associations->order_rows->order_row[$i]->product_attribute_id
and
$xml->cart->associations->cart_rows->cart_row[$i]->id_product_attribute
I'm trying to post a insert on a MySQL database using idHTTP and a PHP script. This is the PHP script to insert in the database:
$mysqli = new mysqli($servidor, $usuario, $senha, $banco);
// Caso algo tenha dado errado, exibe uma mensagem de erro
if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
$iduser = quoted_printable_decode($_POST['iduser']);
$nome = quoted_printable_decode($_POST['nome']);
$data = quoted_printable_decode($_POST['data']);
$hora = quoted_printable_decode($_POST['hora']);
$mensagem = quoted_printable_decode($_POST['mensagem']);
$latitude = quoted_printable_decode($_POST['latitude']);
$longitude = quoted_printable_decode($_POST['longitude']);
$imagem = $_FILES["imagem"]['tmp_name'];
$tamanho = $_FILES['imagem']['size'];
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header('Content-Type: text/plain; charset="utf-8"');
if ( $imagem != "none" )
{
$fp = fopen($imagem, "rb");
$conteudo = fread($fp, $tamanho);
$conteudo = addslashes($conteudo);
fclose($fp);
$queryInsercao = "INSERT INTO tabpainel (iduser, nome, data, hora, mensagem, latitude, longitude, imagem) VALUES ('$iduser', '$nome', '$data','$hora','$mensagem', '$latitude', '$longitude', '$conteudo')";
mysqli_query($mysqli,$queryInsercao) or die("Algo deu errado ao inserir o registro. Tente novamente.");
if (mysqli_affected_rows($mysqli) > 0)
include 'baixarpainel.php';
else
print utf8_encode("Não foi possível inserir o registro");
}
else
print utf8_encode("Não foi possível carregar a imagem.");
?>
And in Delphi, i'm using this:
FormPHP := TIdMultiPartFormDataStream.Create;
FormPHP.AddFile ('imagem', AImagem, 'image/jpeg');
FormPHP.AddFormField ('iduser', AIDUser, 'utf-8');
FormPHP.AddFormField ('nome', ANome, 'utf-8');
FormPHP.AddFormField ('data', AData, 'utf-8');
FormPHP.AddFormField ('hora', AHora, 'utf-8');
FormPHP.AddFormField ('mensagem', AMensagem, 'utf-8');
FormPHP.AddFormField ('latitude', '1');
FormPHP.AddFormField ('longitude', '1');
Response := TStringStream.Create('',TEncoding.UTF8);
HTTP:= TIdHTTP.Create(self);
HTTP.Post('http://addressexample.com/cadastro.php',FormPHP,Response);
It was working fine until a had to change the hosting company. With Hostinger was ok but with Hostgator it doesn't. With Hostgator the idHTTP raise an exception in the class EIdHTTPProtocalException with the message: "HTTP/1.1 406 Not Acceptable". The Hostgator support has already disabled the mod_security, that could cause the problem.
This exception only occurs on Android. Using the same app on Windows, it works fine.
UPDATE: I've tried another thing. The PHP script is this:
// Conecta-se ao banco de dados MySQL
$mysqli = new mysqli($servidor, $usuario, $senha, $banco);
// Caso algo tenha dado errado, exibe uma mensagem de erro
if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
# Instanciando o XMLWriter
$xml = new XMLWriter;
$xml->openMemory();
# Definindo o encoding do XML
$xml->startDocument( '1.0', 'UTF-8');
# Primeiro elemento do XML
$xml->startElement("DATAPACKET");
$xml->writeAttribute("version", "2.0");
$xml->StartElement("METADATA");
$xml->startElement("FIELDS");
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "id");
$xml->writeAttribute("fieldtype", "I4");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "iduser");
$xml->writeAttribute("fieldtype", "String");
$xml->writeAttribute("Width", "30");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "nome");
$xml->writeAttribute("fieldtype", "String");
$xml->writeAttribute("Width", "200");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "data");
$xml->writeAttribute("fieldtype", "String");
$xml->writeAttribute("Width", "8");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "hora");
$xml->writeAttribute("fieldtype", "String");
$xml->writeAttribute("Width", "5");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "mensagem");
$xml->writeAttribute("fieldtype", "String");
$xml->writeAttribute("Width", "3000");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "latitude");
$xml->writeAttribute("fieldtype", "r8");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "longitude");
$xml->writeAttribute("fieldtype", "r8");
$xml->endElement();
$xml->startElement("FIELD");
$xml->writeAttribute("attrname", "imagem");
$xml->writeAttribute("fieldtype", "bin.hex");
$xml->writeAttribute("subtype", "Binary");
$xml->endElement();
$xml->endElement(); //FIELDS
$xml->endElement(); //METADATA
$xml->StartElement("ROWDATA");
# Query na tabela escolhida
$rs_table = $mysqli->query("select * from tabpainel ORDER BY id DESC LIMIT 50");
while($table = $rs_table->fetch_array(MYSQLI_ASSOC))
{
# Transformando array em objeto
$table = (object)$table;
# Criando elemento tabela
$xml->StartElement("ROW");
# Setando os atributos
$xml->writeAttribute("id", "$table->id");
$xml->writeAttribute("iduser", "$table->iduser");
$xml->writeAttribute("nome", "$table->nome");
$xml->writeAttribute("data", "$table->data");
$xml->writeAttribute("hora", "$table->hora");
$xml->writeAttribute("mensagem", "$table->mensagem");
$xml->writeAttribute("latitude", "$table->latitude");
$xml->writeAttribute("longitude","$table->longitude");
$xml->writeAttribute("imagem", base64_encode("$table->imagem"));
$xml->endElement();
}
# Fechando o ROWDATA
$xml->endElement();
# Fechando o elemento DATAPACKET
$xml->endElement();
# Encerrando a conexao
//$con->close();
# Definindo cabecalho de saida
header("content-type: application/xml; charset=utf-8");
# Imprimindo a saida do XML
print $xml->outputMemory(true);
?>
And I used a http.get to receive the xml:
Http.HandleRedirects:= true;
Http.request.useragent := 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; MAAU)';
MS.Text:= Http.get('http://addressexample.com/baixarpainel.php');
MS.SaveToFile(FarquivoBaixado);
And this worked just fine on Android too. The problem remains only http.post on Android.
TIdHTTP works exactly the same way on all platforms, as Indy uses a single cross-platform codebase. So the generated HTTP request should be exactly the same on all platforms.
An HTTP 406 error happens when the HTTP request includes an Accept header that does not specify any media type that the server is capable of rendering the response in. Per RFC 2616 Section 14.1:
If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.
Your PHP script is sending a text/plain response, so if you send an Accept header that does not allow text/plain then that can cause a 406 error. It sounds like Hostgator is enforcing that more than Hostinger does.
By default, TIdHTTP sets its Request.Accept property to the following string value:
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
Which technically allows all media types via */*, but just with a lower priority than some other media types. But that default should still be enough to allow a text/plain response, if the server implements Accept handling correctly.
You need to contact Hostgator and discuss the issue with them, as the problem is on their end, not yours.
That being said, since you know the server response is always text/plain, you could just add the following to your code before calling Post():
HTTP.Request.Accept := 'text/plain';
HTTP.Request.AcceptCharset := 'utf-8';
After long hours trying to solve, this is what happened.
On Windows, the application was working fine, and when I tried using HTTP.GET i imagined that couldn't be on server's end the problem, but on my request. So then, i started opening the headers of request and response both on Windows and Android using this code:
Astr.Add('Response text: ' + Http.Response.ResponseText);
Astr.Add(#13);
Astr.Add('Raw Headers Response: ' + HTTP.Response.RawHeaders.Text);
Astr.Add(#13);
Astr.Add('Raw Headers Request: ' + HTTP.Request.RawHeaders.Text);
This was the message i've got on Android:
Response text: HTTP/1.1 406 Not Acceptable
Raw Headers Response: Server: nginx/1.10.2
Date: ...
Content-Type: text/html;
charset=iso-8859-1
Content-Length:226
Connection: keep-alive
Raw Headers Request: Connection: keep-alive
Content-Type: multipart/form-data; boundary=------(somenumbers)
Content-Length: 0
Host: myhost
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding: identity
User-Agent: ...
And this was the message on Windows
Response text: HTTP/1.1 200 OK
Raw Headers Request: Server: nginx/1.10.2
Date: ...
Content-Type: application/xml
Connection: close
Vary: Accept-Encoding,User-Agent
Raw Headers Request: Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------(numebrs)
Content-Length: 0
Host: myhost
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
User-Agent: ...
The same app on different platforms were sending different headers on Request. On Android, the idHTTP was sending an Accept-Encoding that on Windows was not. So I tried adding this: Http.Request.AcceptEncoding:= '*'; before the HTTP.POST and it worked! I received the xml just as expected.
I don't know why the idHTTP was changing the Request Accept-Encoding, but I had to specify another one and I chose this one because of MDN definition:
*
Matches any content encoding not already listed in the header. This is
the default value if the header is not present. It doesn't mean that
any algorithm is supported; merely that no preference is expressed.
I was able to resolve this issue by simple changing user agent string. I think remote machine(server) has some security installed.
I just set the Request -> UserAgent to:
Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0
and now it works !
I'm trying to update a QB invoice with a payment using the PHP API by Keith Palmer. What I'm doing is:
1) Grab the invoice information (See code bellow)
2) Add a payment
Following this code example:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_payment_add.php
I've created this:
function updateQBInvoice($invoiceNumber = null, $depositAmount = null) {
$this->autoRender = false;
Configure::write('debug', 2);
include(APP."webroot".DS."quickbooks-php".DS."docs".DS."example_app_ipp_v3".DS."config.php");
$IPP = new QuickBooks_IPP($dsn);
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
$IPP->authMode(QuickBooks_IPP::AUTHMODE_OAUTH, $the_username, $creds);
$realm = $creds['qb_realm'];
if ($Context = $IPP->context()) {
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice WHERE DocNumber='".$invoiceNumber."'");
$Invoice = $invoices[0];
$docNumber = $Invoice->getDocNumber();
$CustomerRef = $Invoice->getCustomerRef();
$invoiceId = $Invoice->getId();
$PaymentService = new QuickBooks_IPP_Service_Payment();
$Payment = new QuickBooks_IPP_Object_Payment();
$Payment->setPaymentRefNum($invoiceNumber);
$Payment->setTxnDate(date('Y-m-d'));
$Payment->setTotalAmt($depositAmount);
$Line = new QuickBooks_IPP_Object_Line();
$Line->setAmount($depositAmount);
$LinkedTxn = new QuickBooks_IPP_Object_LinkedTxn();
$LinkedTxn->setTxnId($invoiceId);
$LinkedTxn->setTxnType('Invoice');
$Line->setLinkedTxn($LinkedTxn);
$Payment->addLine($Line);
$Payment->setCustomerRef($CustomerRef);
debug($Payment);
if ($resp = $PaymentService->add($Context, $realm, $Payment)) {
print('Our new Payment ID is: [' . $resp . ']');
} else {
print($PaymentService->lastError());
}
debug('Request [' . $PaymentService->lastRequest() . ']');
debug('Response [' . $PaymentService->lastResponse() . ']');
} else {
echo 'Unable to load a context...?';
}
}
What I've noticed, when getting the invoice info is, all numbers are negatives, and if I assigned them to variable they are {-123}. My response is always:
2030: [Invalid ID, Id should be a valid number. Supplied value:{-10643}]
I imagine I'm setting something wrong somewhere. Would someone care to explain what I'm doing wrong please? Thanks!
UPDATE:
Request:
POST https://quickbooks.api.intuit.com/v3/company/210896252/payment HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="jxw2JuAGtvcg9ynRxXApi8VjcWk%3D", oauth_nonce="uvJB5", oauth_timestamp="1400786567", oauth_token="xxx", oauth_consumer_key="xxx", oauth_version="1.0"
Content-Length: 414
<Payment xmlns="http://schema.intuit.com/finance/v3">
<Line xmlns="http://schema.intuit.com/finance/v3">
<Amount>45</Amount>
<LinkedTxn xmlns="http://schema.intuit.com/finance/v3">
<TxnId>{-10643}</TxnId>
<TxnType>Invoice</TxnType>
</LinkedTxn>
</Line>
<PaymentRefNum>2060</PaymentRefNum>
<TxnDate>2014-05-22</TxnDate>
<TotalAmt>45</TotalAmt>
<CustomerRef>627</CustomerRef>
</Payment>
Response:
HTTP/1.1 400 Bad Request
Date: Thu, 22 May 2014 19:22:47 GMT
Content-Type: application/xml
Content-Length: 278
intuit_tid: c53e5e81-fd5e-4a24-b511-cd6b3449d012
Via: 1.1 ipp-gateway-.net
Vary: Accept-Encoding
Content-Encoding: gzip
Connection: close
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-05-22T12:22:47.834-07:00"><Fault type="ValidationFault"><Error code="2030" element="LinkedTxn.TxnId"><Message>Invalid ID</Message><Detail>Id should be a valid number. Supplied value:{-10643}</Detail></Error></Fault></IntuitResponse>
This highlights your problem here:
<LinkedTxn xmlns="http://schema.intuit.com/finance/v3">
<TxnId>0</TxnId>
<TxnType>Invoice</TxnType>
</LinkedTxn>
You're not setting a valid Id value for the transaction for some reason.
This is probably because of one of two reasons:
You're just not setting a valid TxnId in your code somewhere (if you print out print($Invoice->getId()); what do you see?)
OR
You're using an outdated version of the code from GitHub, which had a but related to this in it (make sure you're using the very latest code from GitHub, as of today)
Hi i asked a question before here : how-can-i-integrate-php-with-my-http-server
i programmed a personal web server and i tried to integrate it with PHP using the PHP-CGI , i run a system command ("PHP-CGI.exe path/to/php/script.php getvar=getValue") and i send the outputs to the browser , everything works cool except that the output shows in the browser as plain/text page like :
X-Powered-By: PHP/5.4.14 Set-Cookie:
PHPSESSID=9rurvleetdkucms44i4cac9a14; path=/ Expires: Thu, 19 Nov 1981
08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0 Pragma: no-cache Content-type: text/html
ID value = AAAA< /h1>
here's the PHP script :
<?php
session_start();
echo "< h1>ID value = < /h1>". $_GET['id'];
?>
and the command i used : php-cgi html_doc/index.php id=AAAA
my question is : why does it send data in plain/text instead of text/html i want?!
and why does it show the header information in the browser like above ?!
Thank you all in advance!
(Notice : i seperated < h1>so it can be appeared!)
this is a BASIC html_to_browser using C sockets
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <strings.h>
int main(int argc, char *argv[]){
char *reply =
"HTTP/1.1 200 OK\n"
"Date: Thu, 19 Feb 2009 12:27:04 GMT\n"
"Server: Apache/2.2.3\n"
"Last-Modified: Wed, 18 Jun 2003 16:05:58 GMT\n"
"ETag: \"56d-9989200-1132c580\"\n"
"Content-Type: text/html\n"
"Content-Length:156\n"
"Accept-Ranges: bytes\n"
"Connection: close\n"
"\n"
"o EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE GRANDE ___2 \n \r\n\r\n"
"THIS IS A HTTP RESPONSE TO BROWSER \n USING C SOCKETS _ \\_t 5 \n \r\n\r\n"
"\r\n\r\n \r\n\r\n \r\n\r\nNOT FINISHED AA _3\r\n\r\n";
int sd = socket(PF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr;
bzero(&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(80);
addr.sin_addr.s_addr = INADDR_ANY;
if(bind(sd,(struct sockaddr*)&addr,sizeof(addr))!=0){
printf("bind error\n");
}
if (listen(sd, 16)!=0){
printf("listen error\n");
}
while(1){
socklen_t size = sizeof(addr);
int client = accept(sd,(struct sockaddr*)&addr, &size);
if (client > 0)
{
printf("client connected\n");
/*send(client, reply, sizeof(reply), 0);*/
send(client, reply, strlen(reply)+1, 0);
}
}
return 0;
}
compile + execute on a console with sudo(to allow port 80) OR change the addr.sin_port to something bigger than '1024'
...ctrl+z to finish
In php you would do header("Content-Type: text/html"); to set a default change the default_mimetype directive in php.INI to the correct mime type.