小编dav*_*xie的帖子

如何在使用Stripe创建订阅后获取费用?

Stripe用作支付网关.现在有一个大问题困扰我.

我使用下面的代码创建订阅:

<?php
require_once('lib/Stripe.php');

Stripe::setApiKey(API_KEY);

$token = $_POST['stripeToken'];

$customer = Stripe_Customer::create(array(
    "card"  => $token,
    "plan"  => $_POST['plan'],
    "email" => "fakeuser@gmail.com",
));
Run Code Online (Sandbox Code Playgroud)

这工作得很好,但我不能Charge ID$customer,我发现有一个在没有办法Stripe API得到它.

如何在创建订阅时获取它?我真的需要Charge ID.

php stripe-payments

12
推荐指数
2
解决办法
1万
查看次数

使用Python 2.7.x连接到Google Analytics时出现403错误

我尝试使用Python客户端(google-api-python-client)从Google Analytics API获取数据.这是我使用的代码:

from apiclient import discovery
from oauth2client.client import SignedJwtAssertionCredentials
from httplib2 import Http

with open("ManagementGate-622edd43c0dd.p12") as f:
    private_key = f.read()

credentials = SignedJwtAssertionCredentials(
    'XXXXXXXX@developer.gserviceaccount.com',
    private_key,
    'https://www.googleapis.com/auth/analytics.readonly')

http_auth = credentials.authorize(Http())

service = discovery.build('analytics', 'v3', http=http_auth)

result = service.data().ga().get(
      ids='ga:79873569',
      start_date='7daysAgo',
      end_date='today',
      metrics='ga:visits,ga:sessions,ga:pageviews').execute()
Run Code Online (Sandbox Code Playgroud)

我在凭据页面上创建了一个服务帐户.但是,我收到如下错误:

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/analytics/v3/data/ga?metrics=ga%3Avisits%2Cga%3Asessions%2Cga%3Apageviews&alt=json&end-date=today&ids=ga%3A79873569&start-date=7daysAgo returned "User does not have any Google Analytics account.">
Run Code Online (Sandbox Code Playgroud)

我所遵循的说明来自:https://developers.google.com/accounts/docs/OAuth2ServiceAccount 还有什么我需要做的吗?为什么我会收到此错误?我已在API页面上启用了Analytics API.

python google-analytics python-2.7 google-api-python-client

6
推荐指数
1
解决办法
3729
查看次数

Google登录无效

我尝试在我的网站上使用Google登录,但是,它一直给我400错误.

我引用了这篇文章:https://developers.google.com/identity/sign-in/web/sign-in,我的代码非常简单:

<html>
<head>
  <title>Test Google Login</title>
  <script src="https://apis.google.com/js/platform.js" async defer></script>
  <meta name="google-signin-client_id" content="<CHANGE IT>">
  <script>
  function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
  }
  </script>
</head>
<body>
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我点击登录按钮时,它弹出一个窗口,登录后,它给了我400错误,如下所示:

400. That’s an error.

The requested URL was not found on this server. That’s all we know.
Run Code Online (Sandbox Code Playgroud)

我想这是重定向问题,但我不知道如何配置它.所以我查了url它还给了我:

https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0
Run Code Online (Sandbox Code Playgroud)

为什么redirect_uri"storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?

google-api google-oauth

5
推荐指数
1
解决办法
1万
查看次数

配置nginx和uwsgi时出现"没有这样的文件或目录"错误

更新:如果我不使用套接字而127.0.0.1:3031改为使用套接字,一切正常.

Nginx版本是1.6.3,uwsgi是2.0.11.1

/etc/uwsgi.ini:

[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
stats = /run/uwsgi/stats.sock
emperor-tyrant = true
cap = setgid,setuid
logto = /var/log/uwsgi.log
Run Code Online (Sandbox Code Playgroud)

/etc/uwsgi.d/daimaduan_preview.ini

[uwsgi]
plugin = python,http
protocol = uwsgi
chdir = /var/www/daimaduan/preview/current
master = true
processes = 4
threads = 20
socket = /tmp/daimaduan-preview.sock
chmod-socket = 666
uid = vagrant
gid = vagrant
logto = /var/log/daimaduan/preview/uwsgi.log
virtualenv = /var/www/daimaduan/preview/venv
wsgi-file = deploy.wsgi
Run Code Online (Sandbox Code Playgroud)

/etc/nginx/conf.d/daimaduan.conf

server {
    listen 80;
    server_name example.com;
    access_log /var/log/daimaduan/preview/access.log; …
Run Code Online (Sandbox Code Playgroud)

python nginx uwsgi

4
推荐指数
1
解决办法
2万
查看次数

类型“typeof client”上不存在“drive”

Angular 5 无法drive从 中找到gapi.client。我所做的是:

package.json:

"@types/gapi.client.drive": "^3.0.0",
Run Code Online (Sandbox Code Playgroud)

tsconfig.app.json:

"types": ["gapi.auth2", "gapi.client", "gapi.client.drive"]
Run Code Online (Sandbox Code Playgroud)

index.html:

<script src="https://apis.google.com/js/platform.js"></script>
Run Code Online (Sandbox Code Playgroud)

我的编辑器(VS Code)和 Angular 都报告如下错误:

Property 'drive' does not exist on type 'typeof client'

,但console.log(gapi.client.drive.files);可以获得我需要的一切。

我这里缺少任何图书馆吗?

google-drive-api angular

4
推荐指数
1
解决办法
1914
查看次数