dan-coulter / phpflickr Goto Github PK
View Code? Open in Web Editor NEWPHP Wrapper for the Flickr API
License: GNU General Public License v2.0
PHP Wrapper for the Flickr API
License: GNU General Public License v2.0
I have a valid key and called
$f = new \AAC\Classes\phpFlickr(getenv('FLICKRAPP')); $recent = $f->photosets_getList();
recent is always coming back as false though.
not sure what I'm going wrong as the troublehooting is minimal.
Hi All
I am trying to display my photos in wordpress and so far I am having problems.
I need to show only specific albums based on articles, so i created a custom field to be populated with album id , which needs to be used with php to get that specific album photos.
So far I am getting this error, Warning: Invalid argument supplied for foreach() .
I even went online and downloaded your sample gallery page and made changes with my api and secret but no luck.
Plz help
Thanks
Last week, my phpFlickr stopped working. I think I see why (http://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/)
I downloaded the latest master version (3.1.1) but still cannot get the example.php to work.
I tried adding the setToken() line but that did not work either.
$f = new phpFlickr("abc123");
$f->setToken("abc-123-456");
$recent = $f->photos_getRecent();
Is there something else I need to be doing? Many thanks for this plugin. I've used it for at least 7 years - it's just great.
Do you plan to update phpFlickr to support this change?
http://code.flickr.net/2014/02/24/new-ssl-endpoints-for-the-flickr-api/
I am currently getting the following error massage for your plugin:
"Warning: Invalid argument supplied for foreach() in /home/abhotel/public_html/widgets/flickr-widget.php on line 66"
Line 66 contains the following code:
foreach ($photos['photoset']['photo'] as $photo):
$info = $f->photos_getInfo($photo['id']);
Ive already updated the flicker api links to https and still getting this error message. It was working last week before Flicker made changes to a https only enviroment. Will I need to changes my api key or is something else causing the problem?
Got it working!
I am getting false response, with no errors. I used my key and secret.
Please, I am not not sure where to look into.
require_once("phpflickr/phpFlickr.php");`
$f = new phpFlickr("<key>","<secret>",true);
$group_url = 'https://www.flickr.com/groups/1529467@N20';
// getting false
$result = $f->urls_lookupGroup($group_url);
var_dump($resultid);
var_dump($f->getErrorCode());
var_dump($f->getErrorMsg());
hi, i have the following code worked fine on a free hosting, but not on localhost?
im using MAMP, maybe i have to change some configurations on the localhost?
My code is something like this:
require_once("../library/flickr/phpFlickr.php");
$api_key = "MY_API_KEY";
$api_secret = "MY_API_SECRET";
$f = new phpFlickr("$api_key", "$api_secret");
$f->setToken('MY_TOKEN'); //token was generated with old http & not with https
$photo_id = "634632477832";
$response = $f->photos_setPerms("$photo_id", 0, 0, 0, 0, 0);
print_r($response);
I am supposed to get $response
like
<photoid secret="abcdef" originalsecret="abcdef">1234</photoid>
but its empty. However it's setting the required permission on the photo.
Also, now, I have to supply each & every parameter/argument for photos_setPerms
, otherwise it doesn't work. With old http-api I could pass only the essential arguments & leave rest as NULL (example: $f->photos_setPerms("$photo_id", 0, NULL, NULL, NULL, NULL)
)
Any idea why?
Hi,
In both sync and async uploads I had issues with error of conversion of array -> string. Turns out that $args had to be converted (encoded) to string. http_build_query did the job but gave me a lot of headache - first saying signature is not good and then not uploading the photos (after I included photo in the image, even though this isn't allowed - i was desperate).
anyways, it turns out that using curl_setopt_array fixed everything. So:
curl_setopt_array($curl, array(CURLOPT_POSTFIELDS => $args));
Hope it helps
@dan-coulter it looks like you're not maintaining this any more. Is that correct? (No worries of course! I don't mean to imply that you should be.)
@ everyone else: is anyone maintaining a current fork of this? There looks to be lots of useful PRs and issues.
:-)
Hello!
I've been useing your wrapper to populate a wordpress site.
All good on my server, everything works as it shoud.
But when i transfer on my client server doesn't work any more.
No mather the request, the reponse is empty.
My server has php 5.3.x , the client server has 5.5.9.
All i can give you is this:
`
phpFlickr Object
(
[api_key] => e54499be5aedef32dccbf89df9eaf921
[rest_endpoint] => https://api.flickr.com/services/rest/
[upload_endpoint] => https://up.flickr.com/services/upload/
[replace_endpoint] => https://up.flickr.com/services/replace/
[req] =>
[response] =>
[parsed_response] =>
[cache] => db
[cache_db] => mysqli Object
(
[affected_rows] => 2
[client_info] => 5.5.46
[client_version] => 50546
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[error_list] => Array
(
)
[field_count] => 0
[host_info] => 127.0.0.1 via TCP/IP
[info] =>
[insert_id] => 0
[server_info] => 5.5.46-0ubuntu0.14.04.2
[server_version] => 50546
[stat] => Uptime: 1599409 Threads: 2 Questions: 69798 Slow queries: 0 Opens: 207 Flush tables: 1 Open tables: 85 Queries per second avg: 0.043
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 1240
[warning_count] => 0
)
[cache_table] => flickr_cache
[cache_dir] =>
[cache_expire] => 604800
[cache_key] => 94a2b731d14562c093c529ff59d4b278
[last_request] => Array
(
[api_key] => e54499be5aedef32dccbf89df9eaf921
[format] => json
[method] => flickr.photosets.getList
[nojsoncallback] => 1
[page] =>
[per_page] =>
[primary_photo_extras] =>
[user_id] => 44052725@N08
)
[die_on_error] =>
[error_code] =>
[error_msg] =>
[token] =>
[php_version] => Array
(
[0] => 5
[1] => 5
[2] => 9
)
[custom_post] =>
[custom_cache_get] =>
[custom_cache_set] =>
[max_cache_rows] => 1000
[secret] =>
[service] => flickr
[cache_request] => Array
(
[api_key] => e54499be5aedef32dccbf89df9eaf921
[format] => json
[method] => flickr.photosets.getList
[nojsoncallback] => 1
[user_id] => 44052725@N08
)
)
`
Hi there! I'm trying to set up a token to view private photos through our Drupal site. When I visit this page, it's broken. Do you have another link that one to use to generate a token?
Thanks!
Running $ php getToken.php
in CLI, I am getting
`Oops! Flickr can't find a valid callback URL.`
How do I run the app. in PHP CLI ?
I'm using sync_upload.. would be nice if the method also return the url for the photo and not just the ID.. i need to embed the photo in the website..
Hello, I've created a testing account on flickr and set up an application in the API garden and gave it delete permissions. However, when I try to upload any photos, I get an error saying that the signature is invalid. I already checked my keys and secrets and everything is right. I don't know what could be happening. Did something change in the API? I can provide any information you want, even my secrets, since it's a testing account.
This one is fine
require_once("phpFlickr.php");
$f = new phpFlickr("<api-key>");
This one is problem
require_once("../dir/phpFlickr/phpFlickr.php");
$f = new phpFlickr("<api-key>");
Any ideas why any call to getToken.php (or anything else that uses pohp flickr) from the command line returns the above error...?
Please, put project to packagist.org to be downloadable by Composer.
I wrote a plugin for wordpress(Flickr Comments) to get the comments from Flickr, and it works fine for more than one year, but recently it refuses to work.
I found it still can communicate with Flickr API, and can get the token but returns no comments.
$comments = $f->photos_comments_getList($flickr_photo_id);
Is the Flickr API changed? or phpFlickr code?
Thanks.
Favorites_getList returns an unexpected boolean type instead of array. It could be that I'm missing something (do I need to edit the script at all?), but this seems like a bug to me.
$apiKey = "MY API KEY";
require_once("includes/phpFlickr.php");
$f = new phpFlickr($apiKey);
$response = $f->favorites_getList(array());
//check that response is array
echo "response: " . gettype($response) . " "; //RETURNS BOOLEAN
It works as expected for photos_search though.
$apiKey = "MY API KEY";
require_once("includes/phpFlickr.php");
$f = new phpFlickr($apiKey);
$response = $f->photos_search(array("tags"=>"mytags"));
//check that response is array
echo "response: " . gettype($response) . " "; //RETURNS ARRAY
PHP error that I'm getting:
PHP Notice: Array to string conversion in PATH-TO-MY-FILE/phpFlickr.php on line 226
Should add
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
To CURL calls
Everything went well until i got these errors. I'm stuck.
( ! )Notice: Array to string conversion in C:\wamp\www\myposter\core\flickr\phpFlickr.php on line 141
( ! ) Notice: Array to string conversion in C:\wamp\www\myposter\core\flickr\phpFlickr.php on line 296
( ! ) Notice: Array to string conversion in C:\wamp\www\myposter\core\flickr\phpFlickr.php on line 226
( ! ) Warning: Cannot modify header information - headers already sent by (output started at
( ! ) C:\wamp\www\myposter\core\flickr\phpFlickr.php:296) in C:\wamp\www\myposter\core\flickr\phpFlickr.php on line 607
Flickr has a nice api for subscribing to push notification. These are
flickr.push.getSubscriptions
flickr.push.getTopics
flickr.push.subscribe
flickr.push.unsubscribe
example url: https://www.flickr.com/services/api/flickr.push.getTopics.html
It would be nice if we have support for them in the api.
Hello,
First of all, thanks for the code, it makes life easier. My question is not directly related to code, but may be interesting. I am trying to create a research related dataset composed of Flickr pictures, however the copyright issue is a big concern. I am not sure if there is an attribute for copyright information of a certain picture. I checked the API documentation, there seems to be nothing about it. Do you know any way around this?
Thanks again, best regards
Before #9, title and description would return a text, after the changes they return an array with _content.
I understand that this is default behavior from Flickr, but this does break applications using the old structure by default.
Was this intentional or something that slipped through?
Line: 367
$size's default value should "medium" (first letter should be capitalized).
It doesn't affect the behavior because using "array_key_exists" check on 391 line, the code "corrects" the falsely set default value to "medium".
I learned the hard way that if CURL is not available then the sockets logic in the post method fails for unicode strings. Unserialize will fail because the reported string lengths will not match the bytecount of the string.
Hi,
The code is fully working if one uses php5-curl, but without the fallback with sockets do not work anymore with the new SSL-only API from Flickr:
in function post
// Use sockets. (line 224)
because it tries to connect to port 80, but even correcting that something else need to be fixed.
Thanks for your code.
Best regards
Is the session_start() on line 22 of the library really required? I can't see any use for it really and it interferes with other PHP software which also requires sessions such as with the Symfony PHP framework where I get an exception when using it with phpFlickr:
Failed to start the session: already started by PHP.
Trying to run on localhost, any suggestions??
Recently, I run in to problem where post function in phpflickr.php file wasn't returning anything.
So, I had to add this is curl request
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
Then everything works fine
And now get the following error:
Fatal error: Call to undefined function: json_decode() in /home/idahosummi/domains/idahosummits.com/public_html/trip_reports/phpFlickr/phpFlickr.php on line 312
Constantly I get this error message:
The Flickr API returned the following error: #98 - Invalid auth token
The problem is here:
/*
$args
Array
(
[api_key] => ...
[auth_token] => Array
(
[_content] => ...
)
[format] => json
[frob] => ...
[method] => flickr.auth.getToken
[nojsoncallback] => 1
[api_sig] => ...
)
*/
$this->response = $this->post($args);
For me, the way it works:
if ($args['method'] == 'flickr.contacts.getList' && isset($args['auth_token']['_content'])) {
$args['auth_token'] = $args['auth_token']['_content'];
}
ksort($args);
$auth_sig = "";
$this->last_request = $args;
$this->response = $this->getCached($args);
Whatever I try, looks like Flickr always returns a "#98 - Invalid auth token" when using setToken. Has anyone gotten this to work?
Hi
I have upgraded the class but all it gives me know is this error.
Warning: Invalid argument supplied for foreach()
I have the code below
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/libraries/flickr/config.php';
require $_SERVER['DOCUMENT_ROOT'] . '/libraries/flickr/phpFlickrUpdate.php';
$flickr = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET);
$token = $flickr->setToken("32532504353251-187bb235325235b");
print_r($token);
$nsid = $token['user']['nsid'];
//$flickr->enableCache("fs",$_SERVER['DOCUMENT_ROOT'] . '/flickr-cache/', -1);
$groups = $flickr->photosets_getList($nsid);
$title = '';
print_r($groups);
foreach ($groups['photoset'] as $value) {
if($value['id'] == $flickrID){
$title = $value['title'];
}
}
$galleries = $flickr->photosets_getPhotos($flickrID);
?>
Now it just doesnt seem to be returning anything via setToken
Please help website has gone down completely.
In the Readme and elsewhere, all links that point to phpflickr.com give a 404 Not Found response. For example: http://www.phpflickr.com/ I tried https://www.phpflickr.com/ but didn't work either.
I've integrated your code in the Drupal flickrapi module. However, it would be ace if I could detect the version from within Drupal so I could alert the user to update to a newer version when needed.
Can you add a changelog.txt with the version number?
hello, i have used your "phpFlickr" for 2 years without any problems (!!), and when flickr.com changed their API/SSL/Https/Etc i have had also update my scripts with the new "phpFlickr".
But the only think i receive now it's "Could not connect to the web service".
I had asked and after changed (to "phpflickr.php" / "auth.php" / "getToken.php") for a new "Flickr API", but nothing changed and doesn't work yet, i have the same sentence "Could not connect to the web service".
I have tried your "example.php" (i changed "foreach ($recent['photos']['photo'] as $photo) {" in the line 21, and the various "http-->https") and still doesn't work, always the same sentence: "Could not connect to the web service".
Do you have any suggestion about my problem?
Thanks in advance, luca.
I ran my joomla firewall and it has identified possible injected script in the following location: /flickr/phpFlickr.php
The script in question is: header("Location: http://www.23hq.com/services/auth/?api_key=" . $this->api_key . "&perms=" . $perms . "&api_sig=". $api_sig)
Is this valid script for mod_expertslider?
My url is todayslifeonline.com
Just want to make sure it isn't valid script that is needed before I delete it.
Thanks
I can't upload a photo because of the following error: The Flickr API returned the following error: #96 - Invalid signature
Methods are missing for the following Flickr APIs:
groups.discuss.replies
groups.discuss.topics
I have manually patched in the ones I need for my own apps.
I've successfully used several methods, and am using them side-by-side in the same script, however, people_findByUsername() does not appear to work.
Do you plan to update phpFlickr to support this change?
http://code.flickr.net/2014/02/24/new-ssl-endpoints-for-the-flickr-api/
Flickr has made a couple of changes to its API that break the current code and example. The API now requires SSL. Modify phpFlickr.php by adding the following two lines after line 227:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
The response has also changed and example.php does not work. Replace code in example.php with the following:
$apiKey = "yourKey";
require_once("phpFlickr.php");
$f = new phpFlickr($apiKey);
$response = $f->photos_getRecent();
//check that response is array
echo "response: " . gettype($response) . "
";
ListResponseElements($response);
function ListResponseElements($response, $indent = "") {
$indent .= " ";
foreach ($response as $key => $value) {
if (is_array($value)) {
echo "$indent array: $key; Count: " . count($value) . "
";
ListResponseElements($value, $indent);
}
else {
//list non-array elements
echo "$indent key: $key; value: $value
";
}
}
}
Return Blank page in browser !
Note: I configured Flickr API probably and phpflckr.php is in correct path
I could read the code and try to find a way to do what I want, but probably someone have already done what I am looking for. I am building a new version of an website where its galleries will be connected with a flickr account. The problem is: I have to get all the pictures that are stored in the old website and create galleries with these pics. The procedure would be:
Get the gallery title from the database >
Create a flicker gallery with this title >
get the id and add pictures from the database to the new created flickr gallery.
Could someone help me how to do that using this wrapper? I tried to find an example but I couldn't find any.
This is an umbrella issue for all "Invalid auth token" issues and maybe even some other issues reporting that phpFlickr is failing recently (#36, #41, #25, #23).
This problem affects applications that have been using phpFlickr since before 26th May 2014 and have updated the submodule to find breakages with "Invalid auth token"s and other breaking changes to the structure of data coming back from Flickr.
To fix, uncomment this line and then comment out the line above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.