试图整合使用PHP的API时收到异常

问题描述 投票:0回答:1

目前,我正在聊天API(它被称为推Chatkit)整合到一个应用程序我的工作。在后端,PHP和laravel正在使用,并且邮差被用来测试服务器。当邮差测试我收到这个异常的500内部服务器错误:

{
    "message": "You must provide an instance_locator",
    "exception": "Chatkit\\Exceptions\\MissingArgumentException",
    "file": "/Users/shaquilenoor/Desktop/chatapi/vendor/pusher/pusher-chatkit-server/src/Chatkit.php",
    "line": 49,
    "trace": [

在跟踪,许多文件/线被称为,所以我抛弃了,因为实在是太适合在这个岗位(你可以问如果需要的话,虽然我可以用它在GDrive的链接)

导致对线+功能的代码被称为是这样的:

<?php

namespace Chatkit;

use Chatkit\Exceptions\ChatkitException;
use Chatkit\Exceptions\ConfigurationException;
use Chatkit\Exceptions\ConnectionException;
use Chatkit\Exceptions\MissingArgumentException;
use Chatkit\Exceptions\TypeMismatchException;
use Firebase\JWT\JWT;

class Chatkit
{
    protected $settings = array(
        'scheme'       => 'https',
        'port'         => 80,
        'timeout'      => 30,
        'debug'        => false,
        'curl_options' => array(),
    );
    protected $logger = null;
    protected $ch = null; // Curl handler

    protected $api_settings = array();
    protected $authorizer_settings = array();
    protected $cursor_settings = array();

    const GLOBAL_SCOPE = 'global';
    const ROOM_SCOPE = 'room';

    /**
     *
     * Initializes a new Chatkit instance.
     *
     *
     * @param array $options   Options to configure the Chatkit instance.
     *                         instance_locator - your Chatkit instance locator
     *                         key - your Chatkit instance's key
     *                         scheme - e.g. http or https
     *                         host - the host; no trailing forward slash.
     *                         port - the http port
     *                         timeout - the http timeout
     */
    public function __construct($options)
    {
        $this->checkCompatibility();

        if (!isset($options['instance_locator'])) {
            throw new MissingArgumentException('You must provide an instance_locator');
        }
        if (!isset($options['key'])) {
            throw new MissingArgumentException('You must provide a key');
        }

        $this->settings['instance_locator'] = $options['instance_locator'];
        $this->settings['key'] = $options['key'];
        $this->api_settings['service_name'] = 'chatkit';
        $this->api_settings['service_version'] = 'v2';
        $this->authorizer_settings['service_name'] = 'chatkit_authorizer';
        $this->authorizer_settings['service_version'] = 'v2';
        $this->cursor_settings['service_name'] = 'chatkit_cursors';
        $this->cursor_settings['service_version'] = 'v2';

        foreach ($options as $key => $value) {
            // only set if valid setting/option
            if (isset($this->settings[$key])) {
                $this->settings[$key] = $value;
            }
        }
    }

该instance_locator是指在推Chatkit,我在我的文件链接,该API的整合产生的代码。这是我第一次使用PHP所以有点失落整合后端服务器!将不胜感激,我应该寻找解决这个问题,也更乐意提供进一步的信息一些建议。干杯

php laravel debugging server pusher
1个回答
1
投票

这取决于你如何创造你应该做这样的事情API请求:

$chatkit = new Chatkit(['instance_locator' => *locator*, 'key' => *actualKey*]);

错误你得到,你有没有在数组传递变量的平均值。

© www.soinside.com 2019 - 2024. All rights reserved.