ID: 42821
Updated by: [EMAIL PROTECTED]
Reported By: admin at anyame dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: cURL related
Operating System: fedora4
PHP Version: 5.2.4
New Comment:
Your code is wrong:
$options = array(CURLOPT_POST => true,
CURLOPT_POSTFIELDS, $postargs,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true);
should be
$options = array(CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postargs,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true);
Previous Comments:
------------------------------------------------------------------------
[2007-10-01 20:52:26] admin at anyame dot co dot uk
Description:
------------
When setting a number of curl options through curl_setopt_array and
using post, the postfields options are not being set properly and are
reported as errored in the response. When the curl_setopt options are
set seperately then the response is valid.
This is for postfields only. Setting the curl options through
curl_setopt_array and seperately for GET work ok
php 5.2.4'./configure' \
'--with-apxs=/usr/local/apache/bin/apxs' \
'--prefix=/usr/local' \
'--with-mysql=/usr' \
'--with-mysqli' \
'--with-openssl' \
'--enable-discard-path' \
'--with-pear' \
'--enable-sockets' \
'--enable-pcntl' \
'--with-xml' \
'--enable-bcmath' \
'--enable-calendar' \
'--with-curl' \
'--with-curlwrappers' \
'--with-dom' \
'--with-dom-xslt' \
'--with-dom-exslt' \
'--enable-ftp' \
'--with-gd' \
'--with-jpeg-dir=/usr/local' \
'--with-png-dir=/usr' \
'--with-xpm-dir=/usr/X11R6' \
'--with-mcrypt' \
'--enable-track-vars' \
'--enable-mbstring' \
'--with-zlib' \
'--with-bz2' \
'--enable-inline-optimization' \
'--disable-debug' \
'--without-pic' \
ini using recommended with short-tags on.
Reproduce code:
---------------
Works - using yahoo webservice example. Freely available at
http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html
------
<?php
error_reporting(E_ALL);
// The POST URL and parameters
$request=
'http://search.yahooapis.com/SiteExplorerService/V1/inlinkData';
$appid = 'YahooDemo';
$query = 'http://search.yahoo.com';
$postargs = 'appid='.$appid.'&query='.urlencode($query).'&results=2';
$ch = curl_init($request);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_HEADER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Output the XML
echo htmlspecialchars($xml, ENT_QUOTES);
ERRORS in xml
-------------
<?php
error_reporting(E_ALL);
// The POST URL and parameters
$request=
'http://search.yahooapis.com/SiteExplorerService/V1/inlinkData';
$appid = 'YahooDemo';
$query = 'http://search.yahoo.com';
$postargs = 'appid='.$appid.'&query='.urlencode($query).'&results=2';
$ch = curl_init($request);
$options = array(CURLOPT_POST => true,
CURLOPT_POSTFIELDS, $postargs,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true);
curl_setopt_array ($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
echo htmlspecialchars($xml, ENT_QUOTES);
Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?> <ResultSet
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:srch" xsi:schemaLocation="urn:yahoo:srch
http://api.search.yahoo.com/SiteExplorerService/V1/InlinkDataResponse.xsd"
totalResultsAvailable="116746" firstResultPosition="1"
totalResultsReturned="2">
<Result><Title>Yahoo!</Title><Url>http://www.schakolad.com/</Url><ClickUrl>http://www.schakolad.com/</ClickUrl></Result>
<Result><Title>Common Dreams | News &amp;
Views</Title><Url>http://www.commondreams.org/</Url><ClickUrl>http://www.commondreams.org/</ClickUrl></Result>
</ResultSet> <!-- se1.search.re4.yahoo.com uncompressed/chunked Mon Oct
1 13:39:48 PDT 2007 --> <!-- ws05.search.re2.yahoo.com
uncompressed/chunked Mon Oct 1 13:39:48 PDT 2007 -->
Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?> <Error xmlns="urn:yahoo:api">
The following errors were detected: <Message>invalid value:
appid</Message> <Message>invalid value: query</Message> </Error> <!--
ws06.search.re2.yahoo.com uncompressed/chunked Mon Oct 1 13:51:02 PDT
2007 -->
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42821&edit=1