validate_sig()) { // ok } else { die("Authentication Failed. Error is: $authObj->sig_validation_error"); } $url = 'http://photos.yahooapis.com/V3.0/uploadPhotos?caption0=Texas%20Capital&desc0=Not%20much%20to%20look%20at'; $url = $authObj->createAuthWSurl($url); if ($url === false) { die("Failed to create authenticated url. Error is: $authObj->access_credentials_error"); } else { // ok } // Create standard multipart form post boundary $boundary = uniqid('------------------'); $MPboundary = '--'.$boundary; $endMPboundary = $MPboundary. '--'; // Create multipart form post per Yahoo! Photos and RFC 1867 // Fetch a photo (you could use a form upload for this) $picture0 = file_get_contents('http://www.ci.austin.tx.us/images/places/plimage19_sm.jpg'); // Create the multipart body. The name and filename are required but are just placeholders. $multipartbody=''; $multipartbody .= $MPboundary . "\r\n"; $multipartbody .= 'Content-Disposition: form-data; name="txcapital"; filename="texascapital.jpg"'. "\r\n"; $multipartbody .= 'Content-Type: image/jpeg'. "\r\n\r\n"; $multipartbody .= $picture0; $multipartbody .= "\r\n". $endMPboundary; // Do the POST // For Photos, the entire URL is handed to curl_init and $multipartbody is the body. $ch = curl_init($url); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $multipartbody); // Add cookie and content-type headers curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Cookie: $authObj->cookie","Content-Type: multipart/form-data; boundary=$boundary")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml = curl_exec( $ch ); if (curl_errno( $ch )) { die("Curl error number:".curl_errno($ch)); } curl_close( $ch ); echo '

The XML below should contain information about your file upload. Check your Yahoo! Photos account for the photo!

'; // Output the XML echo htmlspecialchars($xml, ENT_QUOTES); } else { echo ''; echo ''; echo '

This will upload a small picture of the Texas State Capital to your Yahoo! Photos account

'; echo 'UPLOAD A PHOTO'; echo ''; echo ''; } ?>