2 legged oauth and spreadsheet updating - gdata

I am using the google api to update some spreadsheets (using 2 legged oauth as explained here, except that I check the Two legged access control box ).
Creating the spreadsheets work fine, creating new worksheets inside a spreadsheet also works fine. But I can not seem to interact with the data on the spreadsheet....
I get either:
using listFeed
We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet.
or
using CellFeed
com.google.gdata.util.AuthenticationException
Any ideas ?
Thanks

I ran into both of these errors when learning the Google spreadsheets API. I wish Google did a better job documenting these.
My issue with the listFeed method was that I was using upper case letters and spaces in my GDataSpreadsheetCustomElement names. Google doesn't like this. Here is what I posted on a similar question: Add row in spreadsheet (List-based feed) but it not works
"This very misleading error can occur if the GDataEntrySpreadsheetList you're trying to insert contains no GDataSpreadsheetCustomElements that are relevant to the worksheet.
When creating a GDataSpreadsheetCustomElement, the string you use for "name" must match the value in the first row of the spreadsheet for the column you're interested in, EXCEPT that it must be converted to all lower-case and have all spaces removed."
My issue with authentication using CellFeed was that I was using the wrong FeedURL. The feedURL you want when updating cells is [[worksheet cellsLink] URL]; where worksheet is the GDataEntryWorksheet object for the worksheet you're editing.

Related

Xpath starting retuning None on Scrapy

I'm trying to crawl a site and to do so, I'm using Scrapy. So, when doing requests to nested pages, the procedure usually gets the the information correctly on the first trials, but, on later requests the nodes starts to return None. I'm using xpath's functionality. Below I'm pasting some lines of the parse function:
(I tried this one with the approach of explicitly comparing the class value)
title = response.xpath('//span[#class="inlineFree"]/text()').extract_first()
(With this one I used the contains function)
view = response.xpath('//span[contains(#class,"count")]/text()').extract_first()
(I've also used this one when I found more suitable)
comments = response.css('div.commentMessage > span::text').extract()
Am I doing something wrong on paths?
Is there any reason for the crawler to stop reading the nodes correctly?
Cannot say what the problem is without the log messages or the spider code but..
What happens most of the time is that websites fo not follow a strict html structure .For some properties the 'title' may be inside the span
but for the next iteration it may be
span[#class="inlineFree"]/h1/text() or or any other tag
so you should check the html for those returning None

Why watson Personality Inisights shows different results using different API versions/demo

My apologies if the question is duplicated. We are facing an issue with the analysis of a profile using Watson Personality Insights API in Spanish. We have a demo we implemented using PI API version 2 and then we tested the results (exact same text) with the demo published on developer cloud(in spanish) and we found important differences on how the big five were calculated when the facet values were not that different. Is it possible that these differences are caused because of the API version? The issue that with our demo the big five values produced a kind of negative summary profile when the developercloud summary is kinder.
We could send both result jsons. For example here is how the big five rated:
BigFive DeveloperCloud Demo V2
Openness 0.773834349 0.847273232
Conscientiousness 0.916616088 0.914907481
Extraversion 0.796331544 0.612606551
Agreeableness 0.17445636 0.096118648
Emotional range 0.036287447 0.01623536
thanks in advance!!
So the API version would not make a difference, as that just governs the format of the API; the back-end models are the same for both v2 and v3 of the API.
So the jist of your question is that when you run the same text in your app, and in the demo you get different big5 results, while the facet values are about the same.
This might be easiest solved by you opening a support ticket so we can debug the issue together; if you'd rather not do that then can you provide a sample text? Typically it boils down to a difference in the way the text is parsed.
Another question; did you try making the request using curl? That would cut out any custom logic in your app and narrow down the problem.
thanks Neil for you answer!
We tested the text using CURL and we noticed that the results didn't change by the service version used but instead by how the text was sent. If we called the service using curl passing a plain text input(formatted in UTF-8 with line breaks) it returned the same results for version2 and version 3 and also matched the ones from our demo. If we called the service using curl passing json input WITHOUT line breaks it returned the same values as well. But if we called the service passing the json input WITH line breaks then the results changed and almost matched those shown by ibm demo. My question here is which are the correct results? The ones shown when the text is sent as a plain text input(with line breaks) or when the text is sent as json input(with line breaks)? Is there any technical guideline besides the one shown in developercloud on how the text should be parsed to use this service?
Thanks again!

Expected response code 200, got 400. Unable to convert document

In the last 2 weeks or so, I've suddenly started getting reports of users getting an error in our application saying "Expected response code 200, got 400. Unable to convert document." This is code that has been in place for years without any issue. We are using Zend Framework (GData) in conjunction with Google Docs (AuthSub).
We are logging the issue to a text file when it happens. When it gets logged, the user often tries multiple times (sometimes separated by a few seconds, other times separated by longer times) and it continues to fail. The code in question just creates a new Google document in the user's account and gives it a title (no body content).
Originally, I used this code:
// Create new document
$data = new Zend_Gdata_Docs_DocumentListEntry();
$data->setCategory(
array(new Zend_Gdata_App_Extension_Category(
"http://schemas.google.com/docs/2007#document",
"http://schemas.google.com/g/2005#kind"
)));
$data->setTitle(new Zend_Gdata_App_Extension_Title($title, null));
// Add document to your list
$test = $sharedocs->insertDocument($data, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
To experiment and see if there was an issue with that particular function, I tried creating a blank word doc and changing the code to:
$test = $sharedocs->uploadFile('/mypath/empty.doc', $title, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
However, I'm still seeing the "Unable to convert document" errors. They are relatively infrequent, and I am not able to reproduce the issue on my own computers here. The $title variable does not contain anything unusual (special characters, etc.).
This code was all working fine before -- is there a known issue with the Google Docs API right now? What else can I try?
NOTE: Please see my follow-up comments below, where I have identified the reproducible scenario in which this error occurs.
I had exactly the same problem, but I noticed that I could use the api to save a presentation if not a document... so, it is a terrible hack, but I try to save the document (works if the account has already been accessed)... if that fails, I save and delete a presentation and retry to save the document, which then works. Horrible, horrible, horrible hack

Getting success message from a form that posts data to google spreadsheet

I have been developing a form and have linked it to the Google Docs spreadsheet. So when a user enters details it goes straight to the spreadsheet and populates it. I took the advice from this bit of code here;
http://mashe.hawksey.info/2011/10/google-spreadsheets-as-a-database-insert-with-apps-script-form-postget-submit-method
It works perfectly here: http://betaburo.markdunbavan.co.uk
My only problem is that I want to create a success message and error messages.
There is a bit of code in the main.js file that basically validates it but it is not working or recognising the errors or the success.
Any help would be much appreciated.
Thanks,
Mark
If you use jQuery you can check to see that something has been entered. There are a couple ways to do this.
For example, if you wanted to validate your first name field you could do:
if ($('input#field1').val() == ''){
$('span.successMessage').hide();
$('span.errorMessage').show();
}
else {
$('span.successMessage').show();
$('span.errorMessage').hide();
}
You could also use .serialize on the input, then display the success/error message depending on the length of the serialized entry (i.d. use .length on the serialized entry).

Trying to figure out what {s: ;} tags mean and where they come from

I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.