iOS iap receipt 服务器校验

import json
import requests

SAND_BOX_VERIFY_URL = 'https://sandbox.itunes.apple.com/verifyReceipt'
VERIFY_URL = 'https://buy.itunes.apple.com/verifyReceipt'

#  /**
#          * 服务器二次验证代码
#          * 21000 App Store不能读取你提供的JSON对象
#          * 21002 receipt-data域的数据有问题
#          * 21003 receipt无法通过验证
#          * 21004 提供的shared secret不匹配你账号中的shared secret
#          * 21005 receipt服务器当前不可用
#          * 21006 receipt合法,但是订阅已过期。服务器接收到这个状态码时,receipt数据仍然会解码并一起发送
#          * 21007 receipt是Sandbox receipt,但却发送至生产系统的验证服务
#          * 21008 receipt是生产receipt,但却发送至Sandbox环境的验证服务
#          */


def verify_receipt_with_apple(receipt, is_sandbox=False):
    jsonStr = json.dumps({"receipt-data": receipt})

    headers = {'Content-Type': 'application/json'}
    url = VERIFY_URL
    if is_sandbox:
        url = SAND_BOX_VERIFY_URL
    rep = requests.post(url=url, data=jsonStr, headers=headers)
    # print(rep.text)
    return rep.text


def verify_receipt_with_apple_json(receipt, is_sandbox=False):
    resp = verify_receipt_with_apple(receipt, is_sandbox)
    try:
        json_data = json.loads(resp)
    except:
        return None
    return json_data

if __name__ == "__main__":
    receipt = "MIITrQYJKoZIhvcNAQcCoIITnjCCE5oCAQExCzAJBgUrDgMCGg"

    js = verify_receipt_with_apple_json(recpt, True)

    print(js['receipt'])

    print(js['receipt']['in_app'])
    print(js['receipt']['in_app'][0])

Continue Reading

OSX app 启动后在程序坞不显示

用回mac之后发现各种神奇的问题,比如cocos运行之后在程序坞中找不到,开的窗口多了之后每次想找到他得翻半天(主要是不会各种神奇的快捷键)。

要解决这个问题也不难,退出cocos,在启动台内找到cocos直接拖到程序坞。然后重新启动cocos应该就能出现了

 

已损坏,无法打开。您应该将它移到废纸篓

安装破解版的app或者非appstroe的app经常会遇到这个问题。出现这个情况,通过下面的方法并不能解决:

  1. 系统偏好设置-任何来源“——不管用
  2. 没有任何来源字样,搞定之后勾上任何来源,不管用

实际上问题是出在了mac的quarantine flag上,如果要修复这个问题需要用到下面的命令:

sudo xattr -rd com.apple.quarantine /Applications/xxx.app

com.apple.quarantine属性:

Type: com.apple.quarantine
Subtypes: none
Serialisation: none
Data type: UTF-8 string containing Gatekeeper score, the system time of download, the downloading app or agent, and a UUID for the event
Example: <30303833 3b353833 37316533 633b5361 66617269 2e617070 3b334239 32393643 302d4336 46342d34 3942332d 42414331 2d424342 32323946 46453744 36> «0083;58371e3c;Safari.app;3B9296C0-C6F4-49B3-BAC1-BCB229FFE7D6»
macOS: El Capitan, Sierra, High Sierra
System use: very uncommon
App use: all downloaded apps
Document use: common, notably Zip and other archives which have been downloaded
Other usage: none

Purpose: flags requirement to perform full Gatekeeper check on downloaded app (or executable).
Continue Reading

Mac OSX Guest账号无法登录

去年OSX更新之后Guest账号就无法登录,很久之前发了weibo,@苹果的官方支持,但是也没人理我~~ 这个账号对于自己来说并没有什么太大的用处,但是家里的小朋友有时候会想随便玩玩电脑,假装自己在工作。没有这个账号还真的十分蛋疼。

今天又想到了这个问题,就想看看有什么办法解决这个问题没。整个账号设置看起来十分正常:

 

Continue Reading

OSX pip3 install mysqlclient

在家办公于是将工作环境换到了mac,配置环境的时候安装mysqlclient出现了下面的错误:

(venv_home_mini) obaby@Obabys-Mac-mini taichigameserver % pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "", line 1, in 
      File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup.py", line 16, in 
        metadata, options = get_config()
      File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup_posix.py", line 61, in get_config
        libs = mysql_config("libs")
      File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/

网上搜了一下说安装mysql-connector-c  ,但是安装之后依然报错。于是尝试安装mysql,安装mysql之后解决该问题,其实出问题的地方在于这个命令找不到,如果直接在终端中执行mysql_config如果能够执行成功,那么只需要创建个软连接就可以解决这个问题。

(venv_home_mini) obaby@Obabys-Mac-mini taichigameserver % mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Compiler: AppleClang 11.0.0.11000033
Options:
        --cflags         [-I/usr/local/Cellar/mysql/8.0.19/include/mysql ]
        --cxxflags       [-I/usr/local/Cellar/mysql/8.0.19/include/mysql ]
        --include        [-I/usr/local/Cellar/mysql/8.0.19/include/mysql]
        --libs           [-L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto]
        --libs_r         [-L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto]
        --plugindir      [/usr/local/Cellar/mysql/8.0.19/lib/plugin]
        --socket         [/tmp/mysql.sock]
        --port           [0]
        --version        [8.0.19]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/local/Cellar/mysql/8.0.19/include/mysql]
                pkglibdir     [/usr/local/Cellar/mysql/8.0.19/lib]
                plugindir     [/usr/local/Cellar/mysql/8.0.19/lib/plugin]

安装命令:

brew install mysql

如果没有安装homebrew,通过下面的命令安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  

阿里云 EC2 CentOS 6.0 系统分区扩容

阿里云的虚拟主机磁盘空间满了,这个主要是用来放blog的,所以并没有其他的数据盘。所有的数据都是直接放到/dev/vda1磁盘下的,数据库也是在这个盘下。从阿里云的后台扩容了磁盘发现还需要登陆进行扩容,于是开始按照教程操作,事实证明给出的文档(https://help.aliyun.com/document_detail/25452.html?spm=a2c4g.11186623.6.788.666a3f87QwRXFB)里面方法比较蛋疼,对于扩展系统分区不大适用。 

后来发现貌似看的文档有问题,如果要扩展系统盘应该看这个https://help.aliyun.com/document_detail/111738.html?spm=5176.2020520101.0.0.44d34df5aZCEKE。 这个就尴尬了 smile ,没看好文档。

安装growpart

yum install cloud-utils-growpart

然后对系统分区进行扩容:

growpart /dev/vda 1

Continue Reading

阿里云 安卓push无法收到消息

官方给的demo代码如下:

    request = PushMessageToAndroidRequest.PushMessageToAndroidRequest()
    request.set_AppKey(appKey)
    request.set_Target('ALL')
    request.set_TargetValue('ALL')
    request.set_Title("PushMessageToAndroid title")
    request.set_Body("Message from ali push Open Api2.0 : PushMessageToAndroid")

    request.add_query_param('AndroidNotificationChannel', '1')

    result = clt.do_action(request)
    print result

这个代码有两个问题,如果和另外一份demo代码中的:

clt = client.AcsClient(properties.accessKeyId,properties.accessKeySecret,properties.regionId)

request = PushMessageToAndroidRequest.PushMessageToAndroidRequest()
request.set_AppKey(properties.appKey)
request.set_Target('ALL')
request.set_TargetValue('ALL')
request.set_Title("PushMessageToAndroid title")
request.set_Body("Message from ali push Open Api2.0 : PushMessageToAndroid")
result = clt.do_action(request)

很可能会出现下面的错误信息:



    EABF26DA-89EA-44BA-B16E-117FE03D29C7
    cloudpush.aliyuncs.com
    Throttling.User
    Request was denied due to user flow control.

这个错误信息按照官方的解释是限流了,但是实际并不是,可以尝试分开调用,不要连续进行push message和push notice。

另外一个问题是: 这份代码在对于最新的安卓8.0以上系统的消息无法正常弹出,按照文档解释需要设置NotificationChannel(文档链接:https://help.aliyun.com/knowledge_detail/67398.html)。

Continue Reading