PHPoAuthLib
PHPoAuthLib copied to clipboard
Support to upload Flickr Images
I'm adding a feature to upload Flickr images directly from this lib.
Usage:
$flickrService = $serviceFactory->createService('Flickr', $credentials, $storage, [],
new OAuth\Common\Http\Uri\Uri('https://up.flickr.com/services/upload/')
);
$multipart = '--------------------------' . microtime(true);
$fileName = __DIR__ . '/img.png';
$fileBin = file_get_contents($fileName);
$content = "--" . $multipart."\r\n".
"Content-Disposition: form-data; name=\"photo\"; filename=\"".basename($fileName)."\"\r\n".
"Content-Type: application/png\r\n\r\n".
$fileBin."\r\n";
// signal end of request (note the trailing "--")
$content .= "--" . $multipart . "--\r\n";
$req = $flickrService->request(
'/',
'POST',
$content,
['Content-Type' => 'multipart/form-data; boundary=' . $multipart]
);
$x = simplexml_load_string($req);
$photoId = (string)$x->photoid;
var_dump('<pre>', $x, (string)$x->photoid);