Zend_Gdata_ClientLogin::getHttpClient Issues - api

I am working on a project using the Youtube APIv2.
I am using the API through Zend Framework via Zend Gdata.
My application is querying the youtube api, getting a video feed then for each entry getting the name, thumbs, views, duration and tags for each video entry.
As announced by Google (http://apiblog.youtube.com/2012/08/video-tags-just-for-uploaders.html) now to get the video tags of each video entry the youtube api request as to be authenticated by the user that owns the videos on youtube in order to retrieve these video tags.
What i've done is simply adding a developer key and a httpClient object when I init the *Zend_Gdata_YouTube* object, like that :
$developerKey = 'mydevkey';$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';$idApplication = 'my_app_id';$idClient = null;$httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = 'google_account_email', $password = 'google_account_pass', $service = 'youtube', $client = null, $source = 'my_app', $loginToken = null, $loginCaptcha = null, $authenticationURL);$this->yt = new Zend_Gdata_YouTube($httpClient, $idApplication, $idClient , $developerKey);$this->yt->setMajorProtocolVersion(2);
I tested this piece of code in my project locally inside Mamp Pro and it works perfectly fine, retreiving the video tags as it should be, meaning that the code works.
My problem starts when i wan to put my code on my production server, the *Zend_Gdata_ClientLogin::getHttpClient* object is not working and keeps giving me the error code "Authentication with Google failed. Reason: BadAuthentication"
I checked if someone else was having my problem and i came to this article "http://apiblog.youtube.com/2011/03/clientlogin-fail.html", but neither of the 4 scenarios are similar to my problems.
Could someone help me ? Does my production server is missing something in terms of modules or authorizations (i check it doesn't looks like it).
Thank you.

I had the same problem. My script was working locally, but not in production.
Change your password for a new one and run your script in production first.

Related

Sharepoint error: Likes are not supported in this item

I'm trying to create a Sharepoint iOS app and using the rest api I get the error "Likes are not supported in this item." after doing a POST to https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')/like.
Anyone knows more about this kind of error?
The Rating settings seems to be set correctly on the Sharepoint server, because the like option works correctly on the website, and also in the app I can see the likesCount properties on the response for the Rest API call https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234').
I don't think there is something wrong with the client app implementation, but it is something related to the Sharepoint configuration, although I haven't seen any more settings in regards to the Rating settings including the Sharepoint access for the mobile app.
The web seems to handle this using the Microsoft.Office.Server.ReputationModel.Reputation.setLike function which again works correctly on the web parts, but I couldn't find a way to do it from the mobile app.
To set Likes for the list item, we need use the API below with POST request.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
And pass the data of the POST request as below.
var item = {
"__metadata": { "type": "SP.Data.PagesItem"},
"LikedByStringId": {"results": ["11"]},
"LikesCount": 2
};
Before set Likes for the item, we need get the "LikedByStringId" and "LikesCount" value of the list item using API below with GET request, then set the new one.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
Check the article here: Demonstrates how to like/unlike resource via SharePoint REST API

Kivy app (on android) crashes when attempting to use google directions api

I new to Kivy (and relatively new to Python) and I am having a problem getting UrlRequests to work. In particular, I am trying to use the google directions api in an App for android.
First of all, the code works (completely) when I run the main.py file through python.
The app also successfully builds and deploys to my phone using buildozer. The app loads and runs right up to the point where you press a button to launch a urlrequest, at which point the app just closes.
So I believe the problem is this button. The full details of the button are somewhat unnecessary to explain now I think, but basically it uses a function (like below) several times to return the distance between places.
import urllib2
#the google api key
google_api_key = '...'
def distance_checker(origin, destination):
# This function outputs the distance between two places in meters
api_key = google_api_key
url = 'https://maps.googleapis.com/maps/api/directions/json?origin='
start = origin.replace(' ', '%20')
end = destination.replace(' ', '%20')
final_url = url + start + '&destination=' + end + '&mode=walking' + '&key=' + api_key
json_obj = urllib2.urlopen(final_url)
data = json.load(json_obj)
return data['routes'][0]['legs'][0]['distance']['value']
In my buildozer.spec file I do have 'android.permissions = INTERNET' included.
I also had my app attempt to access google using a function of the form (submitted by user: 10flow, on Pinging servers in Python),
import os
def ping_function(self):
hostname = "google.com" #example
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
self.box.add_widget(Label(text=(hostname + ' is up!'), size_hint_y=None, height=40))
else:
self.box.add_widget(Label(text=(hostname + ' is down!'), size_hint_y=None, height=40))
For clarity, the 'box' used above is for a ScrollView widget. This function does work in the app in android (i.e. it does create a Label saying 'google.com is up!'). So this would lead me to believe that accessing the internet itself is not the problem: the problem is either using a google api, or the using of urllib2 (that make sense?).
I also wrote a function which does the url query using UrlRequest instead of urllib2, but that had the same problem in the end (works on linux, not on android).
So I imagine the problem is using google apis. And I think it has something got to do with adding 'google-play-services_lib/' as an android.library reference in the buildozer.spec file.
If what I have said so far makes sense, could anyone comment on the google api/google-play-services_lib issue? I'm really not that familiar with apis in general, and am somewhat out of my depth. Or perhaps this isn't the issue, and I have missed something obvious.
Anyway, thanks in advance.
EDIT
I think I have narrowed down the problem somewhat. I can use apis that do not require a key, and I cannot use apis that do need a key. Posts like How to get google map apikey in android lead me to believe I just need to add the google api key (in the case of the google directions api) to the android meta data in the buildozer.spec file. I have unsuccessfully tried several variations of the following,
# (list) Android application meta-data to set (key=value format)
android.meta_data = com.google.android.maps.v2.API_KEY=AI...
If anyone could tell me what I am doing wrong it would be very helpful!
Thanks.
So for others and posterity, I found an answer through the Kivy users forum (http://kivy.org/#forum, question: Problems with UrlRequest with an api that needs an api key).
The issue was I was trying to access a https url, and hence needed to build the android apk using openssl. No need for android meta data or google play services, just add openssl to the requirements in the buildozer.spec file.
requirements = openssl,kivy
Once it was discovered that openssl was the issue, there was one more problem to overcome in that buildozer attempted to download an openssl tar file that no longer existed on the openssl.org webpage. However, one can edit the openssl version buildozer attempts to download in your_project/.buildozer/android/platform/python-for-android/recipes/openssl/recipe.sh . You will also need to update the MD5 value in that file.
Hopefully this helps someone in the future.

Downloading YouTube video information, used to work, now not so much

I used to have some code for downloading youtube data and processing it and everything worked fine until google changed something. Was around the time they changed it from 1 channel per account to as many as you want.
This is a sample of the feed that I would download and process but I can’t seem to get it working.
feedUrl = http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads
The code I would use to process it looks like this;
Dim videoFeed As Feed(Of Video) = request.[Get](Of Video)(New Uri(feedUrl))
In the references section, I used to have v2.1 of the google.GData.YouTube, .Extensions & .Client addons and I have updated them to 2.2.
I tried changing the code that processes the line to this but it still doesn’t work.
Dim videoFeed As Feed(Of Google.YouTube.Video) = request.[Get](Of Google.YouTube.Video)(New Uri(feedUrl))
The code runs over the line ok, it’s when it tries to use videoFeed, it throws the error.
intTotalVideos = videoFeed.TotalResults
The error I get is as follows;
Execution of request failed: http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads
I don’t know what changed on the google side, maybe it was the new v3 API or the way you log in via code changed when they let you have multiple channels per account.
If anyone has any advice or where I can find more information, it would be greatly appreciated.
(I tried to find the original code on the net that I used to create the project but was unable to find it sorry.)
According to Developer's Guide: .NET:
The YouTube Data API (v2) has been officially deprecated as of March
4, 2014. Please refer to our deprecation policy for more information.
The following V2 example works for me:
Dim settings As New YouTubeRequestSettings(applicationName, developerKey)
Dim request As New YouTubeRequest(settings)
Dim videoFeed As Feed(Of Video) = request.[Get](Of Video)(New Uri(feedUrl))
Dim intTotalVideos As Integer = videoFeed.TotalResults
Google YouTube SDK .Net Library with version 2.2.0 is used.

Google+ .Net API - Getting Authenticated and retrieving profile

I'm trying to get a users profile information for google+ via the .NET API but am having trouble.
Does anyone know if they have changed how the special ID "me" works?
In the documentation it says this can be used as a special ID to get the currently authenticated users information however this throws a 404 from both the API in my code and on Google's own test page https://developers.google.com/+/api/latest/people/get. I was logged in when trying this.
Does anyone know how to get the user ID as I would happily use that instead of me but it isn't returned after the user authenticates as far as I can see (just an authcode)?
I also tried using user IDs returned when using the standard .net Oauth stuff but it isn't the correct ID, I assume it is for something else.
As for my method of getting to this stage, I first downloaded the example files here: http://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
They don't have a plus example so I took the Tasks.ASP.NET.SimpleOAuth2 example and swapped out tasks (which worked fine) for the plus equivalent.
I also tried rolling this into my own project.
Neither worked. I get the user forwarded to Google where they give me access fine and then when I return they are authenticated successfully as far as I can see, however when I call service.People.Get("me") it returns a 404.
If anyone could help with the above questions (using me, or gettign the user ID) I would appreciate it.
To the moderator who closed the initial version of this question, I have tried to make this as direct a question as possible so please don't close it. This is a legitimate question I would really like help getting to he bottom of.
This is now out of date given recent platform updates. Although the plus.me scope still exists and this code will work, you should be using the plus.login scope for retrieving profile data in C#. For a great way to get started with retrieving and rendering profile information, please start from the Google+ C# quick start available here:
https://developers.google.com/+/quickstart/csharp
First off, the 'me' id still works and is unchanged. The way that it works is:
You authenticate the user using a standard OAUTH2 flow
You use the library to perform a People.get with the special value 'me'
The 404 error code is a little troubling, this means that the client isn't finding the endpoint. To debug this, you might want to use a packet sniffer like fiddler to see what the actual URL it's querying is.
Anyways, how about some C# code. The following example shows how to use the plus service to get the currently authenticated user (assuming you have authenticated someone). What's different from your snippet is that you need to form a get request for the API call, then run fetch on the get request. I've included the following example, for getting 'me', and the following code works:
var auth = CreateAuthenticator();
plusService = new PlusService(auth);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person me = prgr.Fetch();
}
All of the configuration of the server and getting a client working is pretty hard and pasting all of the code here would be less helpful than just giving you a sample.
And so... I have written a sample application that demonstrates how to do this and also includes a wrapper that makes it easier to develop using the Google+ API in C#. Grab it here:
Google+ C# Server-Side demo and library
Seems you need to use:
Person test = service.People.Get("me").Fetch();
and not
req = service.People.Get("me");
Person test = req.Fetch();
Even though they seem to be identical the first works and the second doesn't.
Still not sure why google's own page doesn't work though. Now to find out how to add things to the scope like birthday.

Tumblr API v2 Fails to Upload Valid Photo

Using the blog/{blog-host}/post API call in the v2 oAuth API in order to post a photo, I have a problem with specifying the "source" for the image. The API dictates that this parameter should be the source to an image:
http://www.tumblr.com/docs/en/api/v2#posting
I am using an image on my server, such as this one. The Facebook and other APIs accept and process it correctly:
http://streamified.me/p/d4xh6o/
Unfortunately, I get the following response from Tumblr:
meta = {
msg = "Bad Request";
status = 400;
};
response = {
errors = (
"Error uploading photo."
);
};
Posting other status types works fine...
Well, it looks like I solved the problem. My server was serving the image (the above URL) via a PHP script. Even though the header data etc. was properly sent and the image showed fine in all browsers, the Tumblr API was not recognizing it as an image. Redirecting to a .jpg URL worked fine.
I'd consider this to be a bug in the Tumblr API, but the workaround is "good enough" for me.