Ich habe keine definitive Antwort für Sie, aber ich hatte auch Probleme mit dem API API/0/Edit-Tag und schaffte es, sie zum Laufen zu bringen.
Ich habe bereits andere Teile der API ohne Probleme (API/0/Stream/Elemente/IDs, API/0/ungelesene-Zählung) verwendet, aber dieses war nicht so einfach.
Nach einiger Zeit begann ich mit der Überprüfung der über das Webfrontend an Google Reader gesendeten Anfragen (mithilfe der Chrome-Entwicklungstools) und erstellte ein hartcodiertes Beispiel (Sie können diesen Code verwenden und müssen nur die IDs und ändern streamen Sie für sich selbst - seien Sie vorsichtig, dass sie alle benötigten Präfixe haben: feed/for stream und tag: google.com, 2005: reader/item/für id).
String authToken = getGoogleAuthKey();
// I use Jsoup for the requests, but you can use anything you
// like - for jsoup you usually just need to include a jar
// into your java project
Document doc = Jsoup.connect("http://www.google.com/reader/api/0/edit-tag")
.header("Authorization", _AUTHPARAMS + authToken)
.data(
// you don't need the userid, the '-' will suffice
"a", "user/-/state/com.google/read",
"async", "true",
"s", "feed/http://www.gizmodo.com/index.xml",
"i", "tag:google.com,2005:reader/item/1a68fb395bcb6947",
"T", "//wF1kyvFPIe6JiyITNnMWdA"
)
// I also send my API key, but I don't think this is mandatory
.userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
.timeout(10000)
// don't forget the post! (using get() will not work)
.**post()**;
Hier mein letzter Code wird aus einem Strom ein bestimmtes Elements zum Markieren als gelesen (die translateToItemAtomId Verfahren zum Umwandeln des Long-Integer-IDs verwendet, wie von api/0/Strom/item/IDs in das Atom XML zurück von dieser API akzeptiert ids):
String authToken = getGoogleAuthKey();
Document doc = Jsoup.connect("http://www.google.com/reader/api/0/edit-tag")
.header("Authorization", _AUTHPARAMS + authToken)
.data(
"a", "user/-/state/com.google/read",
"async", "true",
"s", stream,
"i", translateToItemAtomId(itemId),
"T", getGoogleToken(authToken)
)
.userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
.timeout(10000).post();
einige zusätzliche Code können Sie (basierend auf http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/) benötigen:
private static final String _AUTHPARAMS = "GoogleLogin auth=";
private static final String _GOOGLE_LOGIN_URL = "https://www.google.com/accounts/ClientLogin";
private static final String _READER_BASE_URL = "http://www.google.com/reader/";
private static final String _API_URL = _READER_BASE_URL + "api/0/";
private static final String _TOKEN_URL = _API_URL + "token";
private static final String _USER_INFO_URL = _API_URL + "user-info";
private static final String _USER_LABEL = "user/-/label/";
private static final String _TAG_LIST_URL = _API_URL + "tag/list";
private static final String _EDIT_TAG_URL = _API_URL + "tag/edit";
private static final String _RENAME_TAG_URL = _API_URL + "rename-tag";
private static final String _DISABLE_TAG_URL = _API_URL + "disable-tag";
private static final String _SUBSCRIPTION_URL = _API_URL
+ "subscription/edit";
private static final String _SUBSCRIPTION_LIST_URL = _API_URL
+ "subscription/list";
public static String getGoogleAuthKey() throws IOException {
String _USERNAME = "[email protected]";
String _PASSWORD = "USER_PASSWORD";
Document doc = Jsoup
.connect(_GOOGLE_LOGIN_URL)
.data("accountType", "GOOGLE", "Email", _USERNAME, "Passwd",
_PASSWORD, "service", "reader", "source",
"[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
.userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
.timeout(4000).post();
// RETRIEVES THE RESPONSE TEXT inc SID and AUTH. We only want the AUTH
// key.
String _AUTHKEY = doc
.body()
.text()
.substring(doc.body().text().indexOf("Auth="),
doc.body().text().length());
_AUTHKEY = _AUTHKEY.replace("Auth=", "");
return _AUTHKEY;
}
// generates a token for edition, needed for edit-tag
public static String getGoogleToken(String authToken) throws IOException {
Document doc = Jsoup.connect(_TOKEN_URL)
.header("Authorization", _AUTHPARAMS + getGoogleAuthKey())
.userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
.timeout(10000).get();
// RETRIEVES THE RESPONSE TOKEN
String _TOKEN = doc.body().text();
return _TOKEN;
}
hoffe, das hilft!
irgendwelche Updates? Vielen Dank. –
Ich vermute, Sie haben Ihre Anfrage nicht authentifiziert, so dass '/ user/-/state/...' zu einer ungültigen Stream-Antwort führt. –
In welcher Umgebung schreibst du die App? Sie sollten sicherstellen, dass Sie (1) angemeldet sind und das SID-Cookie bei den Anrufen an Google zurückgeben. (2) Stellen Sie sicher, dass Sie die Werte, die Sie in die URL-Zeichenfolge eingeben, per URL codieren. –