Page 1 of 1

PHP: passing data through header

Posted: Tue Aug 03, 2010 9:55 am
by getmizanur
hi, i'm trying to send a simple request and get response however i get response as internal error. parameters "cookie: sessionid", ipaddress and mode are all supposed to be http headers and my json request {"postcode":"EC2A 3AY", "propertyIdentifier":"93A"}

Code: Select all

<?php
$json = '{"postcode":"EC2A 3AY", "propertyIdentifier":"93A"}';

$ch = curl_init();
$header = array(
  'Content-Type: application/json',
  'Set-Cookie: sessionid=aertaert',
  'cookie: sessionid=aertaert',
  'ipaddress: 10.0.0.1',
  'mode: dev'
 );
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://dev.wali.example.co.uk:8280/getAddress');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
curl_close($ch);

var_dump($result);
?>

can someone tell me what am i doing wrong.

many thanks in advance

Re: PHP: passing data through header

Posted: Wed Aug 04, 2010 2:13 am
by atsa1
If your error is: Call to undefined function curl_init()

Then you might look at this.
http://ebay.custhelp.com/cgi-bin/ebay.c ... faqid=1073

Seems like php.ini misconf.