PHP: passing data through header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

PHP: passing data through header

Post 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
atsa1
Forum Newbie
Posts: 20
Joined: Wed Dec 09, 2009 9:11 am

Re: PHP: passing data through header

Post 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.
Post Reply