unable to retrieve picasa photos with php when requesting data feed - php

I tried to retrieve the latest 10 photos from my picasa account but it doesn't work.
$file = file_get_contents("http://picasaweb.google.com/data/feed/api/user/firdawsfm?kind=photo&max-results=10&alt=json&access=public&thumbsize=".$tSize);
print_r($file);
the result :
{"$t":"http://picasaweb.google.com/data/feed/api/user/firdawsfm"},"updated":{"$t":"2013-09-08T19:27:11.010Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind",
"term":"http://schemas.google.com/photos/2007#user"}],
"title":{"$t":"108451527358440546192","type":"text"},
"subtitle":{"$t":"","type":"text"},
"icon":{"$t":"http://lh3.ggpht.com/-Srl88atqmQE/AAAAAAAAAAI/AAAAAAAAAAA/AhcCTIASEAM/s64-c/108451527358440546192.jpg"},
"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml",
"href":"http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt=json"},{"rel":"alternate",
"type":"text/html",
"href":"https://picasaweb.google.com/108451527358440546192"},{"rel":"http://schemas.google.com/photos/2007#slideshow",
"type":"application/x-shockwave-flash",
"href":"https://static.googleusercontent.com/external_content/picasaweb.googleusercontent.com/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt%3Drss"},{"rel":"self","type":"application/atom+xml",
"href":"http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt=json&q=&start-index=1&max-results=10&kind=photo&thumbsize=180c&access=public"}],
"author":[{"name":{"$t":"Firdaws Haskell"},"uri":{"$t":"https://picasaweb.google.com/108451527358440546192"}}],
"generator":{"$t":"Picasaweb",
"version":"1.00",
"uri":"http://picasaweb.google.com/"},
"openSearch$totalResults":{"$t":0},
"openSearch$startIndex":{"$t":1},"openSearch$itemsPerPage":{"$t":10},
"gphoto$user":{"$t":"108451527358440546192"},"gphoto$nickname":{"$t":"Firdaws Haskell"},"gphoto$thumbnail":{"$t":"http://lh3.ggpht.com/-Srl88atqmQE/AAAAAAAAAAI/AAAAAAAAAAA/AhcCTIASEAM/s64-c/108451527358440546192.jpg"}}}
there is no data about photos. when I tried this exemple with another account it works. I verified the photos are public.

I tried your url and all works fine, i can access gphoti$id and media$group values.
So far seems all ok ;) Try again!
Maybe you didn`t have public photos at that time there...
Not relevant answer to that question
(in case if server requests authorisation):
For all Picasa web albums api queries with alt=json, or alt=json-in-code and /userid/default/ you must provide access_token parameter.
Access token you can get using OAuth2 authorization work-flow as described here:
http://code.google.com/p/google-api-php-client/wiki/OAuth2 (using google-api-php-client SDK for example)
And using in scopes this value "http://picasaweb.google.com/data/".
More how to do OAuth2 and get access token from https://accounts.google.com/o/oauth2/token
after requesting user login: https://accounts.google.com/o/oauth2/auth you can find on official website:
https://developers.google.com/accounts/docs/OAuth2Login
In final you must have:
$file = file_get_contents("http://picasaweb.google.com/data/feed/api/user/firdawsfm?kind=photo&max-results=10&alt=json&access=public&thumbsize=".$tSize."&access_token=".$access_token);
print_r($file);

Related

Get the Email-Id of the Client PHP

I want So I've followed the instructions given on the following page
https://developers.google.com/api-client-library/php/auth/web-app
However, it isn't too clear on how to get the currently signed in user's email id. The current scopes that I've set are for reading the person's profile, his email-id and gmail.readonly (reading all emails).
My question is, say I have the access token, and I've initialized the Google_Client object by setting the access token, how do I get the currently sign-in user's email?
Heh, looks like I just needed to find the proper Google Service. Got this by going through the documentation.
https://developers.google.com/resources/api-libraries/documentation/gmail/v1/php/latest/class-Google_Service_Gmail.html
The code now is:
$gmail = new Google_Service_Gmail($client);
if($client->getAccessCode()) {
$token_data = $client->verifyAccessToken();
$email = $token_data['email'];
}
Also, for some reason, the line with $token_data doesn't seem to work, so I ended up using the REST API to verify the access token. Just replace that line with
$token_data = json_decode(file_get_contents('https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='.urlencode($client->getAccessToken()["access_token"])), true);

Vimeo API missing files array in response

I'm trying to get the url of the MP4 file for a public video as a PRO user using Vimeo's API and php library.
$lib = new Vimeo($apiKey, $apiSecret, $accessToken);
$response = $lib->request('/videos/' . $video_id);
var_dump($response['body']);
This is successfully giving me a response from the API, but it is missing the files array that should contain the link to the mp4 file (according to this forum response).
My access token has private, public and interact scopes. Any other reason the files array is missing?
For anyone else experiencing this, it may be caused by a missing 'Video Files' scope on the access token (starting from version 3.3+).
More info: https://github.com/vimeo/vimeo.php/issues/194
PRO users only have access to their own videos. If the access token is authenticated as the owner of $video_id you should be able to see the files key.
If you are unable to see the files key, contact us at https://vimeo.com/help/contact

Getting JSON data from Twitter using ID in PHP

I have a following script which helps me getting data in json format from a particular Facebook ID.
Here's the code
if($recipy_info[0]['social_media']=='facebook')
{
$pageContent = file_get_contents('https://graph.facebook.com/'.$recipy_info[0]['post_userid'].'?fields=id,name,picture,birthday');
$parsedJson = json_decode($pageContent);
//$facebook_info= https://graph.facebook.com/100003384367738?fields=id,name,picture,birthday
}
Now the issue is that I want to have a similar work for Twitter, I don't have screen name, all I have is just the id 1897279429.
I have a url https://api.twitter.com/1.1/trends/1897279429.json, but it gives me this error:
{"errors":[{"message":"Bad Authentication data","code":215}]}
How can I sort my problem?
I want to get JSON data from the id I have.
Since API 1.1 you are required to authenticate first before you can get the public tweets from a user. Please take a look at the API documentation here: https://dev.twitter.com/docs

How to get user image with Twitter API 1.1?

In API 1.0, we can use users/profile_image/:screen_name
For example : http://api.twitter.com/1/users/profile_image/EA_FIFA_FRANCE
But, it doesn't work anymore in API 1.1.
Do you have a solution, please ?
You can also get the twitter profile image by calling this kind of url :
https://twitter.com/[screen_name]/profile_image?size=original
For instance : https://twitter.com/VancityReynolds/profile_image?size=original
Got the info from this post :
https://twittercommunity.com/t/how-to-get-user-image-original-size-with-api-1-1/10187/14
The user's profile image
Okay, so you want a user's profile image. You're going to need to take a look at the twitter REST API 1.1 docs. This is a list of all the different requests you can make to their API (don't worry, I'll get to how you actually do this later on).
There are multiple ways to get the user's profile image, but the most notable one is: users/show. According to the docs for this, the users/show method:
Returns a variety of information about the user specified by the required user_id or screen_name parameter. The author's most recent Tweet will be returned inline when possible.
Well, the user profile image must be in there somewhere, correct?
Let's have a look at a typical response to a request for this information, using the users/show url (we'll use my profile as an example).
I've cut off some from the bottom, because there is a lot of data to go through. Most importantly, you'll see what you require:
This is the profile_image_url key that you need to get access to.
So, how do you do all this? It's pretty simple, actually.
Authenticated Requests
As you rightly pointed out, as of June 11th 2013 you can't make unauthenticated requests, or any to the 1.0 API any more, because it has been retired. So OAuth is the way to make requests to the 1.1 API.
I wrote a stack overflow post with an aim to help all you guys make authenticated requests to the 1.1 API with little to no effort.
When you use it, you'll get back the response you see above. Follow the posts instructions, step-by-step, and you can get the library here (you only need to include one file in your project).
Basically, the previous post explains that you need to do the following:
Create a twitter developer account
Get yourself a set of unique keys from twitter (4 keys in total).
Set your application to have read/write access
Include TwitterApiExchange.php (the library)
Put your keys in a $settings array
Choose your URL and request method (Post/Get) from the docs (I put the link above!)
Make the request, that's it!
A practical example
I'm going to assume you followed the step-by-step instructions in the above post (containing pretty colour pictures). Here's the code you would use to get what you want.
// Require the library file, obviously
require_once('TwitterAPIExchange.php');
// Set up your settings with the keys you get from the dev site
$settings = array(
'oauth_access_token' => "YOUR_ACCESS_TOKEN",
'oauth_access_token_secret' => "YOUR_ACCESS_TOKEN_SECRET",
'consumer_key' => "YOUR_CONSUMER_KEY",
'consumer_secret' => "YOUR_CONSUMER_SECRET"
);
// Chooose the url you want from the docs, this is the users/show
$url = 'https://api.twitter.com/1.1/users/show.json';
// The request method, according to the docs, is GET, not POST
$requestMethod = 'GET';
// Set up your get string, we're using my screen name here
$getfield = '?screen_name=j7mbo';
// Create the object
$twitter = new TwitterAPIExchange($settings);
// Make the request and get the response into the $json variable
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
// It's json, so decode it into an array
$result = json_decode($json);
// Access the profile_image_url element in the array
echo $result->profile_image_url;
That's pretty much it! Very simple. There's also users/lookup which effectively does the same thing, but you can:
Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.
If you ever need to get more than one user's details, use that, but as you only require one user's details, use users/show as above.
I hope that cleared things up a bit!
You say you want to use Twitter API 1.1 and yet you don't want to authenticate your requests.
Unauthenticated requests are not supported in API v1.1. So please adjust to the API change. See updates :
https://dev.twitter.com/blog/planning-for-api-v1-retirement
https://dev.twitter.com/docs/rate-limiting/1.1
You can get image from profile_image_url field of https://api.twitter.com/1.1/users/show.json request. Either a id or screen_name is required for this method. For example :
GET https://api.twitter.com/1.1/users/show.json?screen_name=rsarver
See details here https://dev.twitter.com/docs/api/1.1/get/users/show
I try the above methods to get the profile URL but it does not work for me. I think because Twitter changes API v1.1 to API v2.0.
I found a simple method to get a profile URL.
I use Twitter API v2 there User Lookup -> User by Username API part
Code Sample:
https://api.twitter.com/2/users/by/username/{user_name}?user.fields=profile_image_url
For Example:
https://api.twitter.com/2/users/by/username/TwitterDev?user.fields=profile_image_url
Of course, You should request with your Bearer Token then it properly work. For that, I recommend a platform it calls postman. It really helps for calling API.
Above example code return JSON like this:
{
"data": {
"name": "Twitter Dev",
"profile_image_url": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
"username": "TwitterDev",
"id": "2244994945"
}
}
Additional:
If You want the Profile Image to be a higher size. Then you can put size in place of normal in the URL. For More Details read this one
Like This:
https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_400x400.jpg
Give a vote to help more developers. 🍵
As the previous answers and comments point out:
Twitter API v1.0 is deprecated
Twitter API v1.1 requires OAuth
OP (#Steffi) doesn't want to authenticate
Pick any two; with all three it's a no-go. #Jimbo's answer is correct (and the proper way to do it), but excludes #3. Throwing out #1 means going back in time. But, we can throw out #2, and go directly to the source:
curl -s https://twitter.com/EA_FIFA_FRANCE |
sed -ne 's/^.*ProfileAvatar-image.*\(https:[^"]*\).*$/\1/p'
The sed command just says, find the line that contains "ProfileAvatar-image" and print the substring that looks like a quoted URL.
This is less stable than an authenticated API call, since Twitter may change their HTML at any time, but it's easier than dealing with OAuth, and no official rate limits!
The PHP translation should be straightforward.
try this
http://api.twitter.com/1/users/profile_image/{twitter_account}.xml?size=bigger
In API 1.1 the only way is to connect your application, retrieve the user by
https://dev.twitter.com/docs/api/1.1/get/users/show
and retrieve after his picture
profile_image_url
Hare is a very simple way to get Twitter Profile picture.
http://res.cloudinary.com/demo/image/twitter_name/w_300/{User_Name}.jpg
it's my Profile picutre:
Big: http://res.cloudinary.com/demo/image/twitter_name/w_300/avto_key.jpg
Small: http://res.cloudinary.com/demo/image/twitter_name/w_100/avto_key.jpg
you can regulate size by this part of URL - w_100, w_200, w_500 and etc.

Facebook Photo Upload into Album on Fan Page failed

I have written an Application what posts Photos on a FanPage into a Specific Album long time ago.
Now I didn't used for a half year. Now I had to set up the Application again and grant the extended Permissions to the Fan Page (streamm_publish) again.
But now I've a Problem, I'm using the old REST API what now gives me the error: An unknown error ocurred with the error code 1.
Then I tried to post throught the Facebook Graph api.
I tried to make a call to the Api /pageid/albumid/photos what's not working(Unknown path components)
I tried to makea a call to /albumid_from_my_page/photos then the Photos were posted to my profile
I tried to upload it to /pageid/photos what is the same as the one above
But the code fpr the REST Api worked well, what's the problem there, and why the new Graph Api isn't working how she should?(BUG?)
To post a photo to an album, this is the code:
$post_data = array(
"message" => "My photo caption",
"source" => '#' . realpath($file)
);
$album_id = "XXXXX";
$facebook->api("/$album_id/photos", 'post', $post_data);
Now I suppose to interact with the page albums you need a page access_token added to your $post_data array, for this check this answer.
You need take ACCESS_TOKEN page...
try:
http://graph.facebook.com/me/accounts?access_token= GET THIS TOKEN USING GRAPH API... OR MAKE USING the getAccessToken()...
and will see all pages and aplications that u have, find just application for this case and COPY TOKEN... and damn!!!
It's possible to see this token thought GRAPH API EXPLORER...
regards.

Categories