function ws_images_addFlickr($photo, &$service) { if (!is_admin()) { return new PwgError(403, 'Forbidden'); } global $conf; if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key'])) { return new PwgError(null, l10n('Please fill your API keys on the configuration tab')); } include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'; include_once FLICKR_PATH . 'include/functions.inc.php'; if (test_remote_download() === false) { return new PwgError(null, l10n('No download method available')); } // init flickr API include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php'; $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']); $flickr->enableCache('fs', FLICKR_FS_CACHE); // user $u = $flickr->test_login(); if ($u === false or empty($_SESSION['phpFlickr_auth_token'])) { return new PwgError(403, l10n('API not authenticated')); } // photos infos $photo_f = $flickr->photos_getInfo($photo['id']); $photo = array_merge($photo, $photo_f['photo']); $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original'); $photo['path'] = FLICKR_FS_CACHE . 'flickr-' . $u['username'] . '-' . $photo['id'] . '.' . get_extension($photo['url']); // copy file if (download_remote_file($photo['url'], $photo['path']) == false) { return new PwgError(null, l10n('Can\'t download file')); } // category if (!preg_match('#^[0-9]+$#', $photo['category'])) { $categories_names = explode(',', $photo['category']); $photo['category'] = array(); foreach ($categories_names as $category_name) { $query = ' SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE LOWER(name) = "' . strtolower($category_name) . '" ;'; $result = pwg_query($query); if (pwg_db_num_rows($result)) { list($cat_id) = pwg_db_fetch_row($result); $photo['category'][] = $cat_id; } else { $cat = create_virtual_category($category_name); $photo['category'][] = $cat['id']; } } } else { $photo['category'] = array($photo['category']); } // add photo $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']); // do some updates if (!empty($photo['fills'])) { $photo['fills'] = rtrim($photo['fills'], ','); $photo['fills'] = explode(',', $photo['fills']); $updates = array(); if (in_array('fill_name', $photo['fills'])) { $updates['name'] = pwg_db_real_escape_string($photo['title']); } if (in_array('fill_posted', $photo['fills'])) { $updates['date_available'] = date('Y-m-d H:i:s', $photo['dates']['posted']); } if (in_array('fill_taken', $photo['fills'])) { $updates['date_creation'] = $photo['dates']['taken']; } if (in_array('fill_author', $photo['fills'])) { $updates['author'] = pwg_db_real_escape_string($photo['owner']['username']); } if (in_array('fill_description', $photo['fills'])) { $updates['comment'] = pwg_db_real_escape_string(@$photo['description']); } if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location'])) { $updates['latitude'] = pwg_db_real_escape_string($photo['location']['latitude']); $updates['longitude'] = pwg_db_real_escape_string($photo['location']['longitude']); } if (in_array('level', $photo['fills']) && !$photo['visibility']['ispublic']) { $updates['level'] = 8; if ($photo['visibility']['isfamily']) { $updates['level'] = 4; } if ($photo['visibility']['isfriend']) { $updates['level'] = 2; } } if (count($updates)) { single_update(IMAGES_TABLE, $updates, array('id' => $photo['image_id'])); } if (!empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills'])) { $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']); $raw_tags = implode(',', $raw_tags); set_tags(get_tag_ids($raw_tags), $photo['image_id']); } } return l10n('Photo "%s" imported', $photo['title']); }
function searchFlickrPhotoDetail($id, $type) { $retval = array(); $data = array(); $f = new phpFlickr('5bc169cff7b9121c0c93f9b8804b1116'); $photo = $f->photos_getInfo($id); $tags = ''; foreach ($photo['tags']['tag'] as $tag) { $tags .= $tag['raw'] . ','; //$tag['raw'] } $notes = array(); foreach ($photo['notes']['note'] as $note) { $notes[] = $note['_content']; } $urls = array(); foreach ($photo['urls']['url'] as $url) { $urls = $url['_content']; } $data = array('title' => $photo['title'], 'description' => $photo['description'], 'image' => $f->buildPhotoURL($photo), 'date' => $photo['dates']['taken'], 'author' => $photo['owner']['username'], 'authorUrl' => 'http://flickr.com/photos/' . $photo['owner']['nsid'], 'tags' => $tags, 'note' => $notes, 'url' => $urls); $retval['status'] = 'OK'; $retval['statusmsg'] = 'OK'; $retval['data'] = $data; return $retval; }
function uploadPhoto($path, $title) { $apiKey = "e0fb27a9db978169247afe3169afba43"; $apiSecret = "d9a3f7d933ae7ccf"; $permissions = "write"; $token = "72157662014557483-df831fa3afbc5468"; $f = new phpFlickr($apiKey, $apiSecret, true); $f->setToken($token); $result = $f->sync_upload($path, $title); $photo = $f->photos_getInfo($result); print_r($photo); $src = 'http://farm' . $photo['photo']['farm'] . '.staticflickr.com/' . $photo['photo']['server'] . '/' . $photo['photo']['id'] . '_' . $photo['photo']['secret'] . '.' . $photo['photo']['originalformat']; $src = 'https://c1.staticflickr.com/' . $photo['photo']['farm'] . '/' . $photo['photo']['server'] . '/' . $photo['photo']['id'] . '_' . $photo['photo']['secret'] . '_n.jpg'; echo '<br><img src="' . $src . '">'; }
// Insert your Flickr API here: $f = new phpFlickr("YOUR FLICKR API GOES HERE"); $photos = null; //Cheap-o caching so it's not fetching a list on every refresh. $storedCache = unserialize(file_get_contents("./cache/flickrcache")); if ($storedCache) { if ($storedCache[0] >= time()) { echo "<!-- Cached! -->\n\n"; $photos = $storedCache[1]; } } if (is_null($photos)) { echo "<!-- No cache hit -->\n\n"; $tagToSearch = isset($_REQUEST['tag']) ? $_GET['tag'] : "banana"; // Tag is passed in via query string by requesting HTML. $photos = $f->photos_search(array("tags" => $tagToSearch, "tag_mode" => "all", "per_page" => "500")); // Stick the results in the cache for five minutes $storedCache = array(time() + 300, $photos); file_put_contents("./cache/flickrcache", serialize($storedCache)); } // Pick a random photo from the array of photo objects returned by phpFlickr srand((double) microtime() * 1000000); echo "<!-- Found this many: " . count($photos['photo']) . "-->\n\n"; $randomPhoto = $photos['photo'][rand(0, count($photos['photo']))]; // Construct a link to Flickr's page for the photo. $imgUrl = "http://static.flickr.com/" . $randomPhoto['server'] . "/" . $randomPhoto['id'] . "_" . $randomPhoto['secret'] . ".jpg"; // Get Flickr's info for this photo for use on the credit line. $imgInfo = $f->photos_getInfo($randomPhoto['id'], $randomPhoto['secret']); // Return the display HTML for use by the page (probably in a div). echo "<img src=" . $imgUrl . "><BR>"; echo "<a href='http://www.flickr.com/photos/" . $randomPhoto['owner'] . "/" . $randomPhoto['id'] . "'>" . $imgInfo['title'] . "</a> by <a href='http://www.flickr.com/people/" . $randomPhoto['owner'] . "/'>" . $imgInfo['owner']['username'] . "</a>";
$secret = "065215435996f0d9"; $page = strip_tags($_GET["p"]); //$photos = $f->photosets_getPhotos($photoset_id, null, null, 7, $page ); $photos = $f->people_getPublicPhotos('50369640@N04', null, null, 7, $page); //function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL) echo count($photos); echo gettype($photos); echo implode(",", $photos); echo $photos; print_r($photos['photos']['photo']); //exit; $arr_photos = $photos['photos']['photo']; foreach ($arr_photos as $photo) { print_r($photo); // Build image and link tags for each photo $photoInfo = $f->photos_getInfo($photo['id']); print_r($photoInfo); echo "<li><a href=http://www.flickr.com/photos/" . $photoInfo['photo']['owner']['username'] . "/{$photo['id']}>"; echo "<img border='0' width='768' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Large") . "><div class='metaContainer'><span>" . $photoInfo['photo']['title'] . "</span>"; echo ' </a> <div class="addthis_toolbox addthis_default_style shareBox"> <a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4cd4693368857545" class="addthis_button_compact">Share</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_bookmark"></a> <a class="addthis_button_print"></a> </div> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cd4693368857545"></script> </div>
function execute($par) { global $wgUser, $wgOut, $wgScriptPath, $wgRequest, $wgLang, $wgIFI_FlickrAPIKey, $wgTmpDirectory; global $wgIFI_ResultsPerPage, $wgIFI_FlickrSort, $wgIFI_FlickrLicense, $wgIFI_ResultsPerRow, $wgIFI_CreditsTemplate; global $wgIFI_GetOriginal, $wgIFI_PromptForFilename, $wgIFI_AppendRandomNumber, $wgIFI_FlickrSearchBy, $wgIFI_ThumbType; global $wgIFI_CheckForExistingFile, $wgIFI_ValidDomains, $wgIFI_ValidLicenses; global $wgIFI_UseAjax, $wgIFI_AjaxKey, $wgIFI_AjaxDomain, $wgIFI_AjaxTemplate; require_once "phpFlickr-2.0.0/phpFlickr.php"; wfLoadExtensionMessages('ImportFreeImages'); $this->setHeaders(); $fname = "wfSpecialImportFreeImages"; $importPage = Title::makeTitle(NS_SPECIAL, "ImportFreeImages"); if ($wgUser->isAnon()) { $wgOut->errorpage('uploadnologin', 'uploadnologintext'); return; } if (empty($wgIFI_FlickrAPIKey)) { // error - need to set $wgIFI_FlickrAPIKey to use this extension $wgOut->errorpage('error', 'importfreeimages_noapikey'); return; } $q = ''; if (isset($_GET['q']) && !$wgRequest->wasPosted()) { $q = $_GET['q']; } $import = ''; if ($wgRequest->wasPosted() && isset($_POST['url'])) { $import = $_POST['url']; $parts = parse_url($import); preg_match("/[^.]+\\.[^.]+\$/", $parts['host'], $domain_only); $domain = $domain_only[0]; if (!isset($wgIFI_ValidDomains[$domain])) { $wgOut->addHTML(wfMsg('importfreeimages_invalidurl', $import)); return; } if ($wgIFI_CheckForExistingFile && $wgRequest->getVal('override', null) == null) { $title = urldecode($wgRequest->getVal('ititle')); $id = $wgRequest->getVal('id'); $x = Title::newFromText($title); if ($x) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select("image", array("img_name", "img_description"), array("img_name like '" . $dbr->strencode($x->getDBKey()) . "%'")); $found = false; $wt = ""; while ($row = $dbr->fetchObject($res)) { if (strpos($row->img_description, $id) !== false) { $img = Image::newFromName($row->img_name); $t = Title::makeTitle(NS_IMAGE, $row->img_name); $wt .= "<tr><td>[[Image:{$img->getName()}|thumb|center|{$t->getText()}]]</td>\n\t\t\t\t\t\t\t<td valign='top'>" . wfMsg('image_instructions', $t->getFullText()) . "</td></tr>"; $found = true; } } $dbr->freeResult($res); } if ($found) { $wgOut->addHTML(wfMsg('importfreeimages_similarphotosfound') . "<table>"); $wgOut->addWikiText($wt); $wgOut->addHTML("</table><br clear='all'/><form method='POST'>"); $vals = $wgRequest->getValues(); foreach ($vals as $key => $value) { $wgOut->addHTML("<input type='hidden' name='{$key}' value='" . htmlspecialchars($value) . "'/>"); } $wgOut->addHTML("<input type='hidden' name='override' value='true'/>"); $wgOut->addHTML("<input type='button' onclick='window.location=\"{$importPage->getFullURL()}\";' class='guided-button' value='" . wfMsg('importfreeimages_dontimportduplicate') . "'/> <input class='guided-button' type='submit' value='" . wfMsg('importfreeimages_importduplicate') . "'/></form>"); return; } } if ($wgIFI_GetOriginal && ($domain = "flickr.com")) { // get URL of original :1 $sizes = $f->photos_getSizes($_POST['id']); $original = ''; foreach ($sizes as $size) { if ($size['label'] == 'Original') { $original = $size['source']; $import = $size['source']; } else { if ($size['label'] == 'Large') { $large = $size['source']; } } } //somtimes Large is returned but no Original! if ($original == '' && $large != '') { $import = $large; } } // store the contents of the file $pageContents = file_get_contents($import); $name = $wgTmpDirectory . "/flickr-" . rand(0, 999999); $r = fopen($name, "w"); $size = fwrite($r, $pageContents); fclose($r); chmod($name, 0777); if ($domain == $wgIFI_AjaxDomain) { $caption = "{{{$wgIFI_AjaxTemplate}|{$import}}}"; $id = $wgRequest->getVal('id'); if ($domain == "wikimedia.org") { //maybe we can grab the licnese $yy = str_replace("http://upload.wikimedia.org/", "", $import); $parts = split("/", $yy); $img_title = ""; if (sizeof($parts) == 7) { $img_title = $parts[5]; } else { if (sizeof($parts) == 5) { $img_title = $parts[4]; } } if ($img_title != "") { $url = "http://commons.wikimedia.org/wiki/Image:{$img_title}"; $license = "unknown"; $contents = file_get_contents("http://commons.wikimedia.org/w/index.php?title=Image:{$img_title}&action=raw"); foreach ($wgIFI_ValidLicenses as $lic) { if (strpos($contents, "{{$lic}") !== false || strpos($contents, "{{self|{$lic}") !== false || strpos($contents, "{{self2|{$lic}") !== false) { $license = $lic; break; } } $caption = "{{{$wgIFI_AjaxTemplate}|{$import}|{$url}|{$license}}}"; } } } else { if (!empty($wgIFI_CreditsTemplate)) { $f = new phpFlickr($wgIFI_FlickrAPIKey); $info = $f->photos_getInfo($_POST['id']); $caption = "{{" . $wgIFI_CreditsTemplate . $info['license'] . "|{$_POST['id']}|" . urldecode($_POST['owner']) . "|" . urldecode($_POST['name']) . "}}"; } else { $caption = wfMsg('importfreeimages_filefromflickr', $_POST['t'], "http://www.flickr.com/people/" . urlencode($_POST['owner']) . " " . $_POST['name']) . " <nowiki>{$import}</nowiki>. {{CC by 2.0}} "; } } $caption = trim($caption); $t = $_POST['ititle']; // handle duplicate filenames $i = strrpos($import, "/"); if ($i !== false) { $import = substr($import, $i + 1); } // pretty dumb way to make sure we're not overwriting previously uploaded images $c = 0; $nt =& Title::makeTitle(NS_IMAGE, $import); $fname = $import; while ($nt->getArticleID() && $c < 20) { $fname = $c . "_" . $import; $nt =& Title::makeTitle(NS_IMAGE, $fname); $c++; } $import = $fname; /* $arr = array ( "size" => $size, "tempname" => $name, "caption" => $caption, "url" => $import, "title" => $_POST['t'] ); */ $filename = trim(urldecode($wgRequest->getVal('ititle', null))); if ($filename == "undefined") { $filename = wfTimestampNow(); } $filename .= "_"; if ($wgIFI_AppendRandomNumber) { $filename .= rand(0, 100000); } $parts = parse_url($wgRequest->getVal('url')); $ux = $wgRequest->getVal('url'); $ext = strtolower(substr($ux, strrpos($ux, "."))); switch ($ext) { case ".png": case ".jpeg": case ".jpg": case ".gif": $filename .= $ext; break; default: $filename .= ".jpg"; } $filename = str_replace("?", "", $filename); $filename = str_replace(":", "", $filename); $filename = preg_replace('/ [ ]*/', ' ', $filename); if (!class_exists("UploadForm")) { require_once 'includes/SpecialUpload.php'; } $u = new UploadForm($wgRequest); //MW 1.12+ $u->mTempPath = $name; $u->mFileSize = $size; $u->mComment = $caption; $u->mSrcName = $filename; $u->mUploadTempName = $name; $u->mUploadSize = $size; $u->mUploadDescription = $caption; $u->mRemoveTempFile = true; $u->mIgnoreWarning = true; $u->mOname = $filename; $t = Title::newFromText($filename, NS_IMAGE); if (!$t) { $wgOut->addHTML("Error - could not create title from filename \"{$filename}\""); return; } if ($t->getArticleID() > 0) { $sk = $wgUser->getSkin(); $dlink = $sk->makeKnownLinkObj($t); $warning .= '<li>' . wfMsgHtml('fileexists', $dlink) . '</li>'; // use our own upload warning as we dont have a 'reupload' feature $this->uploadWarning($u); return; } else { $u->execute(); } } $wgOut->addHTML(wfMsg('importfreeimages_description') . "<br/><br/>\n\t\t\t<form method=GET action='" . $importPage->getFullURL() . "'>" . wfMsg('search') . ": <input type=text name=q value='" . htmlspecialchars($q) . "'><input type=submit value=" . wfMsg('search') . ">\n\t\t\t</form>"); if ($q != '') { $page = $_GET['p']; if ($page == '') { $page = 1; } $f = new phpFlickr($wgIFI_FlickrAPIKey); $q = $_GET['q']; // TODO: get the right licenses $photos = $f->photos_search(array("{$wgIFI_FlickrSearchBy}" => "{$q}", "tag_mode" => "any", "page" => $page, "per_page" => $wgIFI_ResultsPerPage, "license" => $wgIFI_FlickrLicense, "sort" => $wgIFI_FlickrSort)); $i = 0; if ($photos == null || !is_array($photos) || sizeof($photos) == 0 || !isset($photos['photo'])) { $wgOut->addHTML(wfMsg("importfreeimages_nophotosfound", $q)); return; } $sk = $wgUser->getSkin(); $wgOut->addHTML("\n\t\t\t\t<style type='text/css' media='all'>/*<![CDATA[*/ @import '/extensions/ImportFreeImages/ifi.css'; /*]]>*/</style>\n\t\t\t\t<div id='photo_results'> " . wfMsg('importfreeimages_results', 'Flickr') . "\n\t\t\t\t<center>\n\t\t\t\t<table cellpadding='4' class='ifi_table'>\n\t\t\t\t<form method='POST' name='uploadphotoform' action='" . $importPage->getFullURL() . "'>\n\t\t\t\t\t<input type='hidden' name='url' value=''/>\n\t\t\t\t\t<input type='hidden' name='id' value=''/>\n\t\t\t\t\t<input type='hidden' name='action' value='submit'/>\n\t\t\t\t\t<input type='hidden' name='owner' value=''/>\n\t\t\t\t\t<input type='hidden' name='name' value=''/>\n\t\t\t\t\t<input type='hidden' name='ititle' value=''/>\n\t\t\t\t</form>\t\n\t\t<script type=\"text/javascript\">\n\t\n\t\t\tfunction s2 (url, id, owner, name, ititle) {\n\t\t\t\tresults = document.getElementById('photo_results');\n\t\t\t\tdocument.uploadphotoform.url.value = url;\n\t\t\t\tdocument.uploadphotoform.id.value = id;\n\t\t\t\tdocument.uploadphotoform.owner.value = owner;\n\t\t\t\tdocument.uploadphotoform.name.value = name;\n\t\t\t\tdocument.uploadphotoform.ititle.value = ititle;\n\t\t\t\tif (" . ($wgIFI_PromptForFilename ? "true" : "false") . ") {\n\t\t\t\t\tititle = ititle.replace(/\\+/g, ' ');\n\t\t\t\t\tdocument.uploadphotoform.ititle.value = prompt('" . wfMsg('importfreeimages_promptuserforfilename') . "', unescape(ititle));\n\t\t\t\t\tif (document.uploadphotoform.ititle.value == '') {\n\t\t\t\t\t\tdocument.uploadphotoform.ititle.value = ititle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdocument.uploadphotoform.submit();\n\t\t\t\tresults.innerHTML = '" . wfMsg('importfreeimages_uploadingphoto') . "';\n\t\t\t}\n\t\n\t\t</script>\n\t\t\t\t"); $count = 0; foreach ($photos['photo'] as $photo) { $count++; if ($i % $wgIFI_ResultsPerRow == 0) { $wgOut->addHTML("<tr>"); } $owner = $f->people_getInfo($photo['owner']); $wgOut->addHTML("<td><a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'>"); $wgOut->addHTML($photo['title']); $wgOut->addHTML("</a><br/>" . wfMsg('importfreeimages_owner') . ": "); $wgOut->addHTML("<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>"); $wgOut->addHTML($owner['username']); $wgOut->addHTML("</a><br/>"); //$wgOut->addHTML( "<img src=http://static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . "." . "jpg>" ); $url = "http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}.jpg"; $wgOut->addHTML("<img src=\"http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_{$wgIFI_ThumbType}.jpg\">"); $wgOut->addHTML("<br/>(<a href='#' onclick=\"s2('{$url}', '{$photo['id']}','{$photo['owner']}', '" . urlencode($owner['username']) . "', '" . urlencode($photo['title']) . "');\">" . wfMsg('importfreeimages_importthis') . "</a>)\n"); $wgOut->addHTML("</td>"); if ($i % $wgIFI_ResultsPerRow == $wgIFI_ResultsPerRow - 1) { $wgOut->addHTML("</tr>"); } $i++; } if ($count == 0) { $wgOut->addHTML(wfMsg('importfreeimages_noresults')); } $wgOut->addHTML("</table></center>"); if ($wgIFI_UseAjax) { $s = htmlspecialchars($wgRequest->getVal('q')); $gPage = ($page - 1) * 2; $importjs = HtmlSnips::makeUrlTags('js', array('importfreeimages.js'), '/extensions/ImportFreeImages/', false); $wgOut->addHTML("<br/><br/>" . wfMsg('importfreeimages_results', $wgIFI_AjaxDomain) . "\n\t\t\t\t\t<script type='text/javascript'>\t\t\t\n\t\t\t\t\t\tvar gAjaxDomain = '{$wgIFI_AjaxDomain}';\n\t\t\t\t\t\tvar gInitialSearch = '{$s}';\n\t\t\t\t\t\tvar gPage = {$gPage};\n\t\t\t\t\t\tvar gImportMsg = '" . wfMsg('importfreeimages_importthis') . "';\n\t\t\t\t\t\tvar gImportMsgManual = '" . wfMsg('importfreeimages_importmanual') . "';\n\t\t\t\t\t\tvar gManualURL= '" . Title::makeTitle(NS_PROJECT, 'Manual Import')->getFullURL() . "';\n\t\t\t\t\t\tvar gMoreInfo='" . wfMsg('importfreeimages_moreinfo') . "';\n\t\t\t\t\t</script>\n\t\t\t\t <script src='http://www.google.com/jsapi?key={$wgIFI_AjaxKey}' type='text/javascript'></script>\n\t\t\t\t\t{$importjs}\n\t\t\t\t \t<div id='searchform' style='width:200px; display:none;'>Loading...</div>\n\t \t\t\t<div id='ajax_results'></div>\n\t\t\t\t"); } $page = $page + 1; $wgOut->addHTML("</form>"); $wgOut->addHTML("<br/>" . $sk->makeLinkObj($importPage, wfMsg('importfreeimages_next', $wgIFI_ResultsPerPage), "p={$page}&q=" . urlencode($q))); $wgOut->addHTML("</div>"); } }
</td> <?php if (!(($key + 1) % 3)) { echo "</tr>\n<tr>"; } } echo "</tr></table>"; } else { echo "No matching pictures were found.<!-- refresh me -->"; } } } elseif ($this->attributes['details']['show'] == "advanced") { if (isset($this->attributes['details']['photos']) && count($this->attributes['details']['photos']) > 0) { echo "<table cellpadding='3' style='border: none; width: 100%'>\n<tr>"; foreach (split(",", $this->attributes['details']['photos']) as $key => $photoID) { $photo = $f->photos_getInfo($photoID); $isError = $f->getErrorMsg(); if (!$isError) { if (!isset($photo['urls']['url']) || count($photo['urls']['url']) < 1) { //$photopage = "http://www.flickr.com/photos/" . $photo['owner']['nsid'] . "/" . $photo['id'] . "/"; $photopage = "http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id']; } else { foreach ($photo['urls']['url'] as $photopage) { if ($photopage['type'] == "photopage") { $photopage = $photopage['_value']; } } } ?> <td style="vertical-align: top; text-align: center; width: 33%"> <a href="<?php
/** * Accept a request to upload an image either via POST data (user upload) * or via flickr or google / wikimedia.org search. * * @param $src string with value 'upload', 'flickr' or 'wiki' * @return html outputs image details page */ private function uploadImage($src, $fromIIA = false) { global $wgRequest, $wgUser, $IP, $wgOut; $error = ''; $debugInfo = array(); if ($src == 'upload') { $tempname = TempLocalFile::createTempFilename(); $file = new TempLocalFile(Title::newFromText($tempname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo()); $name = $wgRequest->getFileName('wpUploadFile'); $file->upload($wgRequest->getFileTempName('wpUploadFile'), '', ''); $comment = ''; $filesize = $file->getSize(); if (!$filesize) { $error = wfMsg('eiu-upload-error'); } } elseif ($fromIIA || $src == 'flickr' || $src == 'wiki') { $sourceName = $fromIIA || $src == 'flickr' ? 'Flickr' : 'Mediawiki Commons'; $tempname = TempLocalFile::createTempFilename(); $file = new TempLocalFile(Title::newFromText($tempname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo()); $details = (array) json_decode($wgRequest->getVal('img-details')); $name = $details['name']; // scrape the file using curl $filename = '/tmp/tmp-curl-' . mt_rand(0, 100000000) . '.jpg'; $remoteFile = strlen($details['url_l']) ? $details['url_l'] : $details['url']; $ch = curl_init($remoteFile); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $fp = fopen($filename, 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); $ret = curl_exec($ch); $err = curl_error($ch); curl_close($ch); fclose($fp); if ($err) { $debugInfo['curl'] = $err; } $filesize = @filesize($filename); if ($filesize) { if ($fromIIA || $src == 'flickr' || preg_match('@^http://[^/]*flickr@', $details['url'])) { require_once $IP . '/extensions/3rdparty/phpFlickr-2.3.1/phpFlickr.php'; $flickr = new phpFlickr(WH_FLICKR_API_KEY); $photo = $flickr->photos_getInfo($details['photoid']); $err = $flickr->getErrorMsg(); if ($err) { $debugInfo['flickrAPI'] = $err; } $license = $photo['license']; $username = $photo['owner']['username']; $comment = '{{flickr' . intval($license) . '|' . wfEscapeWikiText($details['photoid']) . '|' . wfEscapeWikiText($details['ownerid']) . '|' . wfEscapeWikiText($username) . '}}'; } else { $comment = self::getWPLicenseTag($details['url']); } // finish initializing the $file obj $status = $file->upload($filename, '', ''); if (!$status->ok) { $error = wfMsg('eiu-upload-error'); } } else { $error = wfMsg('eiu-download-error', $sourceName); } } if ($error) { $html = EasyTemplate::html('eiu_file_error.tmpl.php', array('error' => $error)); $wgOut->addHTML($html); error_log("file from {$src} error msgs: " . print_r($debugInfo, true)); } else { $mwname = $tempname; if (!$fromIIA) { $props = array('src' => $src, 'name' => $name, 'mwname' => $mwname, 'is_image' => $file->media_type == 'BITMAP' || $file->media_type == 'DRAWING', 'width' => $file->width, 'height' => $file->height, 'upload_file' => $file, 'image_comment' => $comment, 'license' => $wgUser->getOption('image_license')); $html = EasyTemplate::html('eiu_image_details.tmpl.php', $props); $wgOut->addHTML($html); } else { $this->insertImage('', $name, $mwname, true, $comment); } } }
$defwords = substr($defwords, 0, strLen($defwords) - 4); //this will eat the last OR //echo $defwords; unset($argst); $argst = array("text" => "" . $defwords . "", "min_taken_date" => "" . $fsdate . "", "max_taken_date" => "" . $fedate . "", "per_page" => "20", "sort" => "relevance", "page" => "1"); //print_r($argst); $triathlondaily = $f->photos_search($argst); //print_r($triathlondaily); for ($x = 0; $x <= 15; $x++) { $photosre = ''; $photosre = $triathlondaily[photo][$x]; $photo_id = ''; $photo_id = $triathlondaily[photo][$x][id]; //echo $photo_id; // need to find photo username to get data to allow form piciture flickr url $photoid = $f->photos_getInfo($photo_id, $secret); //print_r($photoid); //echo $photoid[urls][url][$x][_content]; $image = $f->buildPhotoURL($photosre, $size = "Thumbnail"); $imgtoday[$x][url] = $photoid[urls][url][0][_content]; $imgtoday[$x][title] = $photoid[title]; $imgtoday[$x][image] = $image; //print_r($imgtoday); } //closes forloop /*<div class="rphoto"><a href="<?php echo $photoid[urls][url][0][_content]?>" title="<?php echo $photoid[title]?>"><img src="<?php echo $image ?>" border ="1" /></a></div> */ if ($imgtoday) { $db->query = "INSERT INTO " . RSSDATA . ".imagesource (idstart, orderid, imgurl, title, sourceurl, enddate) VALUES "; foreach ($imgtoday as $key => $meimg) { $smeurl = mysql_real_escape_string($meimg[url]);
<?php require_once 'phpFlickr.php'; $flickrObject = new phpFlickr("46dea5f6abb12aed7a823adb7ecf5816"); $pics_file = fopen("pics_file_temp.txt", "w") or die("Unable to open file!"); $photos = $flickrObject->photos_search(array("tags" => "trip,travel,vacation,objects,color,- people,- person,- bikini,- human", "tag_mode" => "any", "per_page" => "50", "sort" => "interestingness-desc", "content_type" => "1", "safe_search" => "1", "license" => "9")); //Initializing variables $imageCounter = 0; $idArrayImages = array(); //For each Picture foreach ($photos['photo'] as $photo) { //Console Log image message counter echo "Image: " . $imageCounter++ . " / "; //We get the Information of each photo giving the Photo_ID $photo_info = $flickrObject->photos_getInfo($photo['id']); echo $photo["id"] . ' - '; if (in_array($photo['id'], $idArrayImages)) { echo "Hay una imagen repetida"; } $idArrayImages[] = $photo['id']; //Uncomment this line to see the PUBLIC URL of the photo //echo $photo_info['photo']['urls']['url'][0]['_content']."\n"; //We stract the TAGS array for each photo $array_tags = $photo_info['photo']['tags']['tag']; //Get the different sizes of the image $photo_sizes = $flickrObject->photos_getSizes($photo['id']); //We look the optimal size foreach ($photo_sizes as $size) { //Only get Medium Images for file sizes proposes if ($size['label'] == 'Medium 640') { $url = $size['source'];
} ?> <div class="flickr"> <?php $url_elements = parse_url($node->field_flickr[0]['embed']); $flickr_path = explode('/', $url_elements['path']); if (module_exists('keys')) { $flickr_api_key = keys_get_key('flickr_theme_helper'); } $f = new phpFlickr($flickr_api_key, NULL, FALSE); if (module_exists('fenchurch')) { $f->enableCache('db', fenchurch_flickr_cache_db_url(), variable_get('fenchurch_flickr_cache_lifetime', 64000)); } $flickr_photo_info = $f->photos_getInfo($flickr_path[3]); ?> <?php print $node->field_flickr[0]['view']; ?> <?php if ($node->location) { $photo_latitude = $node->location['latitude']; $photo_longitude = $node->location['longitude']; if (function_exists('theme_gmap') && $page) { $photo_markers = array('id' => 'photo_markers', 'zoom' => 11, 'width' => '500px', 'height' => '200px', 'type' => 'Map', 'text' => $node->title, 'latitude' => $photo_latitude, 'longitude' => $photo_longitude, 'markers' => array(array('markername' => '', 'latitude' => $photo_latitude, 'longitude' => $photo_longitude))); print theme('gmap', array('#settings' => $photo_markers)); } // function_exists('theme_gmap')
} /* ------------------------------------ :: GRID ONLY ------------------------------------ */ if ($NV_show_slider == 'gridgallery') { $output .= '<div class="nv-sortable row">'; } /* ------------------------------------ :: GRID ONLY *END* ------------------------------------ */ foreach ($photos['photoset']['photo'] as $photo) { $photodata = $f->photos_getInfo($photo['id']); if ('video' == $photodata['photo']['media']) { $sizes = $f->photos_getSizes($photo['id']); $NV_movieurl = $sizes[6]["source"]; // Movie File URL $NV_videotype = 'swf'; $NV_previewimgurl = ''; } else { $NV_previewimgurl = $f->buildPhotoURL($photo, $img_size); // Preview Image URL } $NV_posttitle = $photo['title']; $NV_description = $photo['description']; $NV_disablegallink = ''; $NV_galexturl = 'http://www.flickr.com/photos/' . $user; $NV_disablereadmore = 'yes';
echo '<img src="' . $f->buildPhotoURL($photo, $viewsize) . '" title="' . $photo['title'] . '" />'; echo '</a>'; echo '</td>'; $row = 6; if ($viewsize == "square" || $viewsize == "thumbnail") { $row = 6; } elseif ($viewsize == "small") { $row = 3; } else { $row = 1; } if ($count % $row == 0) { echo '</tr><tr>'; } } echo '</tr>'; echo '</table>'; /************************************************************************************************/ /** * Show page with photos */ } elseif ($todo == "getphoto") { $photo_id = $_REQUEST['photo_id']; $insertsize = $_REQUEST['insertsize'] == "" ? "small" : $_REQUEST['insertsize']; $linksize = $_REQUEST['linksize'] == "" ? "medium" : $_REQUEST['linksize']; require_once "phpFlickr.php"; $f = new phpFlickr($api_key); $photo = $f->photos_getInfo($photo_id); echo '<a href="' . $f->buildPhotoURL($photo, $linksize) . '" title="' . $photo['title'] . '"><img src="' . $f->buildPhotoURL($photo, $insertsize) . '" alt="' . $photo['title'] . '" title="' . $photo['title'] . '" /></a>'; /************************************************************************************************/ }
// if it's not a dead link, then we can make API calls! $url_elements = parse_url(check_url($node->field_url['0']['display_url'])); if (strstr($url_elements['host'], 'flickr.com') && !strstr($url_elements['path'], "tags")) { $flickr_path = explode('/', $url_elements['path']); if (!class_exists('phpFlickr')) { require_once fenchurch_flickr_library_path() . '/phpFlickr.php'; } if (module_exists('keys')) { $flickr_api_key = keys_get_key('flickr_theme_helper'); } $f = new phpFlickr($flickr_api_key, NULL, FALSE); if (module_exists('fenchurch')) { $f->enableCache('db', fenchurch_flickr_cache_db_url(), variable_get('fenchurch_flickr_cache_lifetime', 64000)); } if ($flickr_path[1] == 'photos' && is_numeric($flickr_path[3])) { $flickr_photo_info = $f->photos_getInfo($flickr_path[3]); $thumbnail_url = 'http://farm' . $flickr_photo_info['farm'] . '.static.flickr.com/' . $flickr_photo_info['server'] . '/' . $flickr_photo_info['id'] . '_' . $flickr_photo_info['secret'] . '_s.jpg'; } else { if ($flickr_path[1] == 'photos' && $flickr_path[3] == 'sets') { $flickr_photo_set_info = $f->photosets_getInfo($flickr_path[4]); $flickr_photo_info = $f->photos_getInfo($flickr_photo_set_info['primary']); $thumbnail_url = 'http://farm' . $flickr_photo_info['farm'] . '.static.flickr.com/' . $flickr_photo_info['server'] . '/' . $flickr_photo_info['id'] . '_' . $flickr_photo_info['secret'] . '_s.jpg'; } } } if ($thumbnail_url) { print '<div class="website-thumbnail">'; $thumbnail = theme('image', $thumbnail_url, $title, '', NULL, FALSE); $link_attributes = array(); $link_attributes['rel'] = $dead_link ? 'nofollow' : NULL; $link_attributes['html'] = TRUE;
public function getItems() { jimport('joomla.filesystem.folder'); $api_key = '2a4dbf07ad5341b2b06d60c91d44e918'; $cache_path = JPATH_ROOT . '/cache/test/flickr'; $nsid = ''; $photos = array(); // create cache folder if not exist JFolder::create($cache_path, 0755); if (!class_exists('phpFlickr')) { require_once 'api/phpFlickr.php'; } $f = new phpFlickr($api_key); $f->enableCache('fs', $cache_path, $this->get('cache_time')); //enable caching if ($this->get('flickr_search_from') == 'user') { $username = $this->get('flickr_search_from'); if ($username != NULL) { $person = $f->people_findByUsername($username); $nsid = $person['id']; } else { return ''; } $photos = $f->people_getPublicPhotos($nsid, NULL, NULL, $this->get('item_count')); $source = $photos['photos']['photo']; } if ($this->get('flickr_search_from') == 'tags' or $this->get('flickr_search_from') == 'text') { $tags = $this->get('flickr_attrs'); if (!empty($tags)) { $attrs = ''; if ($this->get('flickr_search_from') == 'tags') { $attrs = 'tags'; } if ($this->get('flickr_search_from') == 'text') { $attrs = 'text'; } $photos = $f->photos_search(array($attrs => $tags, 'per_page' => $this->get('item_count'))); $source = $photos['photo']; } else { return ''; } } if ($this->get('flickr_search_from') == 'recent') { $photos = $f->photos_getRecent(NULL, $this->get('item_count')); $source = $photos['photo']; } //$extras = 'description,date_upload,owner_name,tags'; $items = array(); $i = 0; if (count($source) > 0) { foreach ($source as $photo) { $id = $photo['id']; $obj = new stdClass(); $info = $f->photos_getInfo($id); $nsid = $info['owner']['username']; $obj->title = $info['title']; $obj->image = $f->buildPhotoURL($photo, '_b'); $obj->link = $info['urls']['url'][0]['_content']; $obj->introtext = $info['description']; $obj->date = date('Y.M.d : H:i:s A', $info['dateuploaded']); $items[$i] = $obj; $i++; } } //return $items; var_dump($f); }
?> margin-top: 10px; border-top: 1px solid #000;"> <div style="margin-bottom: 10px; padding: 5px;"> <h2>Enter links to photo pages on Flickr (one per line)</h2> Example: http://www.flickr.com/photos/bees/61752182/ <textarea name="bulkLoader" id="bulkLoader" rows="5" cols="50"></textarea> <input type="button" value="Go" onclick="return checkPhotos()" /> </div> <ul id="bulkList"> <?php if (isset($module->details['photos'])) { require_once "lib/phpFlickr/phpFlickr.php"; $f = new phpFlickr("91463f56021a88799ecbf0eb105a08fd ", NULL, false); foreach (split(",", $module->details['photos']) as $photoID) { $photo = $f->photos_getInfo($photoID); if ($f->getErrorCode()) { continue; } else { ?> <li><input type="checkbox" name="modules[id<?php echo $module->lens_module_id; ?> ][details][photos][]" value="<?php echo $photo['id']; ?> " checked="checked" /> <img src="http://static.flickr.com/<?php echo $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret']; ?> _s.jpg" align="middle" style="border:1px solid black; padding:1px; margin-right: 10px">
{ // all OK } else { mkdir($cacheFolderPath); } $lifetime = 860 * 860; // 60 * 60=One hour $f->enableCache("fs", "$cacheFolderPath", "$lifetime"); } ?> <?php if ($flickrCaption == "1") : ?> <div id="gallery"> <div class="photosets"> <?php $photos = $f->photosets_getPhotos($flickrSet, NULL, NULL, $flickrNumber); ?> <?php foreach ($photos['photoset']['photo'] as $photo): $d = $f->photos_getInfo($photo['id']); ?> <div class="photos"> <ul> <li> <a href="#"><img src="<?= $f->buildPhotoURL($photo, $flickrThumb) ?>" data-large="<?= $f->buildPhotoURL($photo, 'large') ?>" alt="<?= $photo['title'] ?>" data-description= "<?= $photo['title'] ?>" data-href="<?= $f->buildPhotoURL($photo, 'large') ?>" /></a> </a> </div> <?php endforeach ; ?> </div> </li> </ul> </div> </div> </div> </div> </div>
function getFlickrPhotoInfo($itemId) { global $wgHTTPProxy; $flickrAPI = new phpFlickr('bac0bd138f5d0819982149f67c0ca734'); $proxyArr = explode(':', $wgHTTPProxy); $flickrAPI->setProxy($proxyArr[0], $proxyArr[1]); $flickrResult = $flickrAPI->photos_getInfo($itemId); // phpFlickr 3.x has different response structure than previous version return $flickrResult['photo']; }
} $flickr_user = $f->people_findByUsername($flickr_username->value); // Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($flickr_user["id"]); if (!empty($flickr_user)) { $recent = $f->people_getPublicPhotos($flickr_user['id'], NULL, NULL, 5); } else { echo "user not found"; die; } //echo "<pre>"; var_dump( $recent ); echo "</pre>"; //echo "<pre>"; var_dump( $user ); echo "</pre>"; $body = elgg_view_title("Flickr photos for {$flickr_user['username']}"); $count = 0; foreach ($recent['photos']['photo'] as $photo) { $photo_info = $f->photos_getInfo($photo["id"], $photo["secret"]); $body .= "<div class='tidypics_album_images'>"; $body .= "{$photo_info['title']}<br />Views: {$photo_info['views']}<br />"; $body .= "<a href={$photos_url}{$photo['id']}>"; $body .= "<img border='0' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Square") . ">"; $body .= "</a>"; $tag_count = 0; $body .= "<br /><div style='font-size: 8px;'>Tags:<br />"; foreach ($photo_info["tags"]["tag"] as $tag) { if ($tag_count) { $body .= ", "; } $body .= "{$tag['_content']}"; $tag_count++; } $body .= "</div></div>";
require_once "phpFlickr.php"; $f = new phpFlickr("cdebb75fb498222416d23dce91618f9a", "065215435996f0d9"); $photoset_id = "72157624682260557"; $secret = "065215435996f0d9"; $page = strip_tags($_GET["p"]); //$photos = $f->photosets_getPhotos($photoset_id, null, null, 7, $page ); $photos = $f->people_getPublicPhotos('50369640@N04', null, null, 7, $page); //function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL) // changed by b3d $arr_photos = array($photos['photoset']['photo']); foreach ($arr_photos as $photo) { //foreach ($photos['photoset']['photo'] as $photo) { // end b3d // Build image and link tags for each photo $photoInfo = $f->photos_getInfo($photo[id]); echo "<li><a href=http://www.flickr.com/photos/" . $photoInfo['owner']['username'] . "/{$photo['id']}>"; echo "<img border='0' width='768' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Large") . "><div class='metaContainer'><span>" . $photoInfo['title'] . "</span>"; echo ' </a> <div class="addthis_toolbox addthis_default_style shareBox"> <a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4cd4693368857545" class="addthis_button_compact">Share</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_bookmark"></a> <a class="addthis_button_print"></a> </div> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cd4693368857545"></script> </div> </li>';
function flickrbadge($params = array()) { $defaults = array('key' => false, 'username' => false, 'limit' => 10, 'format' => 'square', 'cache' => true, 'refresh' => 60 * 60 * 2); $options = array_merge($defaults, $params); // check the cache dir $cacheDir = c::get('root.cache') . '/flickrbadge'; dir::make($cacheDir); // disable the cache if adding the cache dir failed if (!is_dir($cacheDir) || !is_writable($cacheDir)) { $options['cache'] = false; } if (!$options['key']) { return false; } if (!$options['username']) { return false; } $cacheID = 'flickrbadge/data.' . md5(serialize($options)) . '.php'; if ($options['cache']) { $cache = cache::modified($cacheID) < time() - $options['refresh'] ? false : cache::get($cacheID); } else { $cache = false; } if (!empty($cache)) { return $cache; } $flickr = new phpFlickr($options['key']); $userCacheID = 'flickrbadge/user.' . md5($options['username']) . '.php'; $userCache = $options['cache'] ? cache::get($userCacheID) : false; $user = false; $url = false; if (!empty($userCache)) { $user = a::get($userCache, 'user'); $url = a::get($userCache, 'url'); } if (!$user || !$url) { $user = $flickr->people_findByUsername($options['username']); $url = $flickr->urls_getUserPhotos($user['id']); if ($options['cache']) { cache::set($userCacheID, array('user' => $user, 'url' => $url)); } } $photos = $flickr->people_getPublicPhotos($user['id'], NULL, NULL, $options['limit']); $result = array(); foreach ($photos['photos']['photo'] as $photo) { $photoCacheID = 'flickrbadge/photo.' . $photo['id'] . '.php'; $info = $options['cache'] ? cache::get($photoCacheID) : false; if (empty($info)) { $info = $flickr->photos_getInfo($photo['id']); if ($options['cache']) { cache::set($photoCacheID, $info); } } $info = a::get($info, 'photo', array()); $dates = a::get($info, 'dates', array()); $tags = array(); foreach ((array) $info['tags']['tag'] as $t) { if (!empty($t['raw']) && !$t['machine_tag']) { $tags[] = $t['raw']; } } $result[] = new obj(array('url' => $url . $photo['id'], 'title' => a::get($info, 'title', $photo['title']), 'description' => @$info['description'], 'src' => $flickr->buildPhotoURL($photo, $options['format']), 'taken' => isset($dates['taken']) ? strtotime($dates['taken']) : false, 'posted' => isset($dates['posted']) ? $dates['posted'] : false, 'lastupdate' => isset($dates['lastupdate']) ? $dates['lastupdate'] : false, 'views' => a::get($info, 'views', 0), 'comments' => a::get($info, 'comments', 0), 'tags' => $tags)); } $result = new obj($result); if ($options['cache']) { cache::set($cacheID, $result); } return $result; }
} ?> <?php if ($flickrCaption == "1") { ?> <div id="gallery"> <div class="photosets"> <?php $photos = $f->photosets_getPhotos($flickrSet, NULL, NULL, $flickrNumber); ?> <?php foreach ($photos['photoset']['photo'] as $photo) { $d = $f->photos_getInfo($photo['id']); ?> <div class="photos"> <ul> <li> <a href="#"><img src="<?php echo $f->buildPhotoURL($photo, $flickrThumb); ?> " data-large="<?php echo $f->buildPhotoURL($photo, 'large'); ?> " alt="<?php echo $photo['title']; ?> " data-description= "<?php
<?php include_once "../include.php"; require_once "./phpFlickr-3.1/phpFlickr.php"; $f = new phpFlickr("94c57f05ba55563f88348d29bdd54593"); $id = $_GET['id']; $owner = $f->photos_getInfo($id); $retval = new obj(); $retval->status = 0; $retval->statusMsg = sprintf("success"); $retval->raw = $owner; $retval->data = $owner; echo json_encode($retval);