I have the task of converting the following block of PHP code to execute multi-page HTTP mail. I understand the basics of executing HTTP messages (my code is already reporting some JSON), and I read about the basic principles of multidisciplinary requests. However, Curl obviously does a lot of work on its feet behind the scenes, which needs to be converted to a .NET stream entry. However, with these things, the devil is in the details.
Not familiar with Curl and be a newbie to PHP, is there a way, using the code, to see a request that is finally sent with curl_exec? A real life example will really help. In fact, I'm fine with simple fields - each of which has a separate border / part. This is a JPEG image encoding, which is complicated for me. Could I set up the PHP environment and somehow debug it? I conclude that Curl is a kind of web client, i.e. It does a lot of what a web browser does without a user interface.
<?php
function AddPhoto( $account, $password, $pubId, $photoId, $owner, $pubDate, $attribution, $caption, $keywords, $photoPath )
{
$args = array( 'Method' => 'AddPhoto', 'Account' => 'Test', 'Password' => 'pw',
'PubID' => 'WOR/1002',
'PhotoID' => '12345',
'Owner' => 'me',
'PubDate' => '2015-07-01',
'Attribution' => '',
'Caption' => 'the front door',
'Keywords' => 'Pub',
'Photo' => new CurlFile( $photoPath,
'image/jpeg',
'image'
)
);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://dev.camrapubs.org.uk/simon/PubDatabase/API2.php');
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $args );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
return curl_exec($ch);
}
$result = AddPhoto( ‘xx', ‘xx', 'WOR/1002', '12345', 'me', '2015-07-01', 'copyleft', 'The front door', 'Pub', 'sample.jpg' );
echo 'result = ', $result, PHP_EOL;
?>