【问题标题】:Getting GotoMeeting access token using PHP CURL使用 PHP CURL 获取 GotoMeeting 访问令牌
【发布时间】:2019-08-17 01:15:10
【问题描述】:

我正在创建一个 Wordpress 插件,它会在一些交易后创建一个会议,但我不知道如何获取令牌。我做了一些测试,但似乎没有用。

尝试做一些post CURL。

$consumerKey = "consumer_key_here";
$url = "https://api.getgo.com/oauth/v2/authorize?client_id={$consumerKey}&response_type=code"; 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
$test = curl_exec($ch);
if (curl_error($ch)) {
    echo curl_error($ch);
}
print $test;

这应该被重定向到所需的重定向 url,并带有参数响应代码。

【问题讨论】:

    标签: php wordpress curl


    【解决方案1】:

    要对这些值进行编码,请打开encoding site 并粘贴consumerKey,添加冒号(:),然后粘贴consumerSecret。没有空格,没有引号,没有括号。提交值并返回一个编码值,类似于:ZXhhbXBsZV9jbGllbnRfaWQ6ZXhhbXBsZV9jbGllbnRfc2VjcmV0==

    $ch = curl_init();
    if($ch) {
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
        $token="for this you need to use documentation ";
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Authorization: Basic '.$token,'Accept:application/json'));
    
        $curlulr="https://api.getgo.com/oauth/v2/token";
        curl_setopt($ch, CURLOPT_URL, $curlulr);
        curl_setopt($ch, CURLOPT_POST, true);
    
        $data = 'grant_type=authorization_code'.
        '&code={responseKey}';
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    
        $rmv_results = curl_exec($ch);
        if($rmv_results === false) {
            echo('Error performing rmv lookup: '.curl_errno($ch).' - '.curl_error($ch).' (Message ID: '.basename(__FILE__).'-'.__LINE__.')');
        } // end if errors
        // echo "3";
        curl_close($ch);
    
        print_r($rmv_results);
        echo ">><br>". $rmv_results;
    }
    

    【讨论】:

    • 要对这些值进行编码,请打开一个编码站点 (base64encode.org (link is external)) 并粘贴 consumerKey,添加一个冒号 (:),然后粘贴到 consumerSecret。没有空格,没有引号,没有括号。提交值并返回一个编码值,如下所示:ZXhhbXBsZV9jbGllbnRfaWQ6ZXhhbXBsZV9jbGllbnRfc2VjcmV0==。
    • 在您的答案中包含相关信息,而不是作为评论。 (防止投票失败)。
    猜你喜欢
    • 1970-01-01
    • 2016-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-27
    • 2019-02-14
    • 1970-01-01
    • 2021-11-01
    相关资源
    最近更新 更多