所以我试图同步到谷歌文档,而不必询问用户他的凭据.我使用此代码获取auth-token:
AccountManager mgr = AccountManager.get(activity);
authToken = mgr.blockingGetAuthToken(account, DocsService.DOCS_SERVICE, true);
Run Code Online (Sandbox Code Playgroud)
这将返回一个看起来格式良好的身份验证令牌.所以在我的DocsService上运行:
service.setAuthSubToken(authToken);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用API时,我只获得了AuthenticationException.有关如何处理此错误的任何想法?
编辑:我确实拥有USE_CREDENTIALS权限.
这是我在这个网站上的第一个问题.我是php的新手但是我已经按照建议尽可能地弄脏了它.不幸的是现在我有点难过这个简单的Youtube应用程序,我正在努力创建.
我知道有几个相关的问题,但我还没有找到一个全面的解决方案来解决我的问题.
无论如何,我要做的是在youtube频道中获取视频的网址,提取视频ID并创建一个数组,然后我可以传递给javascript函数以获得一些很酷的客户端内容.
到目前为止,这是我的代码.我很确定我的问题与数组与字符串以及方法内外的变量有关.在任何情况下,我的array_map函数都不起作用,showFullFeed()函数只返回一个值而不是链接数组.
任何帮助都是很有帮助的.干杯
class ChannelFeed {
function __construct($username) { $this->username=$username; $this->feedUrl=$url='http://gdata.youtube.com/feeds/api/users/'.$username.'/favorites'; $this->feed=simplexml_load_file($url); }
public function getYTid() {
$ytURL = $this->feed->entry->link['href'];
$ytvIDlen = 11; // This is the length of YouTube's video IDs
// The ID string starts after "v=", which is usually right after // "youtube.com/watch?" in the URL $idStarts = strpos($ytURL, "?v=");
// In case the "v=" is NOT right after the "?" (not likely, but I like to …
我正在构建一个库以访问Google Analytics Data Export API.库访问的所有数据都是Atom格式,并且在整个过程中使用了许多不同的命名空间.到目前为止,我使用API进行的实验已经使用SimpleXML进行解析,尤其是我所做的就是访问feed中保存的数据.
现在我要写一个库我想知道是否适合使用SimpleXML是否足够,或者PHP中DOM模块的增强功能是否会在将来有所帮助.我还没有为这部分库编写太多代码,所以选择仍然是开放的.
我已经读过,如果您需要动态构建XML DOM或修改现有的XML DOM,那么PHP DOM模块可能是更好的选择,但由于API的性质,我不能完全确定我是否需要该功能(例如,没有将数据推送到服务器).SimpleXML当然更容易使用,我见过有人说只读情况就是你需要的.
基本上问题是,你会用什么?兼容性不会成为问题,因为服务器配置将符合应用程序的要求.是否值得用PHP DOM构建库,或者我现在应该坚持使用SimpleXML?
更新:以下是我将要处理的Feed类型的两个示例:
如何获取谷歌搜索结果网址?
(我使用Zend_Gdata_Gbase获取搜索谷歌搜索结果而不是DomDocument/htmlsimpleparser,因为它看起来Zend_Gdata_Gbase专门用于解析谷歌搜索结果.如果我的选择错误,请写.)
我的功能是获取'yahoo'或其他查询搜索字符串的google搜索结果:( 该函数获取的搜索结果应该包含'yahoo'字样,但是当我使用prin_t($ feed)时,我看不到网址每个结果)
<?php
function queryGoogleSearch($queryString='yahoo'){
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('['.$queryString.']');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('4');
$feed = $service->getGbaseSnippetFeed($query);
return $feed;
}
print_r(queryGoogleSearch());
?>
Run Code Online (Sandbox Code Playgroud)
我得到4个第一个网址结果(当我在谷歌手动搜索时):
www.yahoo.com,mail.yahoo.com,search.yahoo.com,maps.yahoo.com
但是当我打印$ feed变量时,我找不到它们.
请问我应该更改或添加inqueryGoogleSearch()函数?(或其他更好的代码)
谢谢
我想访问Google分析数据,我从Google数据API SDK获取样本.但是这些编码不起作用并抛出异常
请求的执行失败:https://www.google.com/analytics/feeds/accounts/default
所以我发现原因是Google将其更新为v3.0.我搜索了C#的更新编码,但我找不到解决方案.
我有同样的问题,但用C#. 使用GData .NET Analytics API时抛出异常
我尝试使用以下更改进行编码,如Google开发者所述 - https://developers.google.com/analytics/resources/articles/gdata-migration-guide#appendix_a
string userName = this.Username.Text;
string passWord = this.Password.Text;
AnalyticsService service = new AnalyticsService("AnalyticsSampleApp");
service.setUserCredentials(userName, passWord);
string googleAccountWebId = "AIXXXXXXXXXXXXXXXXXXXXXXXXXXX";
string profileFeedUrl = "https://www.googleapis.com/analytics/v2.4/data?key=" + googleAccountWebId;
DataQuery query2 = new DataQuery(profileFeedUrl);
query2.Ids = "12345678";
query2.Metrics = "ga:visits";
query2.Sort = "ga:visits";
query2.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("2011-08-01");
query2.GAEndDate = DateTime.Now.ToString("2013-09-01");
query2.StartIndex = 1;
DataFeed data = service.Query(query2);
foreach (DataEntry entry in data.Entries)
{
string st=entry.Metrics[0].Value;
}
Run Code Online (Sandbox Code Playgroud)
但即使我改变它,它也会抛出异常
DataFeed data = …
使用user.profile和user.email作用域以及/ oauth2/v2/userinfo feed似乎不会返回任何自定义字段(在我的案例中为Department)或电话号码.这些字段显示在"域共享联系人"目录中.
是否有类似于Apps域特定的供稿网址//oauth2/{DOMAIN}/v2/userinfo?
API /服务不支持任何自定义字段吗?
有没有办法将其捏造成工作?
对您自己的应用程序域共享联系人配置文件的读访问权限应该不会那么困难.
我更喜欢非管理员解决方案,因为我的域使用具有SAML身份验证的公共访问卡,所以我不能只在App Engine应用程序中存储管理员凭据(用户:密码)并访问/ m8/feed.如果有一个流程来访问具有预先授权的消费者密钥和秘密的域共享联系人(带有自定义字段),我会对使其工作的说明感兴趣.
编辑 Jay Lee钉了它" https://www.google.com/m8/feeds/gal/ {domain}/full"
以下是使用Google Apps脚本的概念验证脚本(我完成后会添加最终的OAuth2版本)
function getGal(email, passwd, domain) {
var res = UrlFetchApp.fetch("https://www.google.com/accounts/ClientLogin", {
contentType: "application/x-www-form-urlencoded",
method: "post",
payload: { "Email": email, "Passwd": passwd, "accountType": "HOSTED", "service":"cp" }
});
var auth = res.getContentText().match(/Auth=(.*)/i)[1];
Logger.log("Auth: " + auth);
res = UrlFetchApp.fetch("https://www.google.com/m8/feeds/gal/" + domain + "/full", {
method: "get",
headers: { "Authorization": "GoogleLogin auth=" + auth, "GData-Version": "1.0" }
});
Logger.log(res.getHeaders());
Logger.log(res.getContentText());
}
Run Code Online (Sandbox Code Playgroud)
编辑2返回JSON的OAuth版本,仅返回访问脚本的用户的信息.
function googleOAuthM8() { …Run Code Online (Sandbox Code Playgroud) POM.xml :
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>****</groupId>
<artifactId>****</artifactId>
<version>1.0</version>
</parent>
<groupId>com.web</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<name>web</name>
<url>http://maven.apache.org</url>
<dependencies>
dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
DB Connection Pooling -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Hibernate Validator -->
<!-- Form Validation using Annotations -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId> …Run Code Online (Sandbox Code Playgroud) 是否已经有任何解决方案如何使用Zend Gdata Framework在Google日历中插入/编辑/删除事件.自11月17日以来它不起作用.
谢谢
如何使用Zends GData Library创建一个新的空电子表格?
我已经使用我设置的有效令牌进行了会话:
$session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
// Store the session token in our session.
$_SESSION['cal_token'] = $session_token;
Run Code Online (Sandbox Code Playgroud)
然后我希望能够这样做:
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$docs = new Zend_Gdata_Docs($client);
$feed = $docs->getDocumentListFeed();
Run Code Online (Sandbox Code Playgroud)
但是使用令牌.而不是使用user/pass/service进行身份验证
我已经看过一些这样的例子,但我没有找到任何方法让它工作.
谢谢大家!
gdata ×10
php ×4
gdata-api ×3
zend-gdata ×2
android ×1
api ×1
arrays ×1
c# ×1
google-api ×1
google-apps ×1
guava ×1
java ×1
oauth ×1
simplexml ×1
spreadsheet ×1
youtube ×1