2016-10-13 2 views
0

Facebook Graph APIで動作するCodeigniter 3.2でWebアプリケーションを作成しています。 POST HTTP要求をGET &にするには、Codeigniter用のカールライブラリが必要です。私はGuzzleを見つけましたが、CodeigniterでGuzzleを使用する方法はわかりません。Guzzle on Codeigniterの使い方は?

+0

私の意見は、カールが使用することは困難ではありませんということで、そのGuzzle(非常に滑らかではあるが)は、あなたのニーズに重大な過剰なものです。 [PHP cURLマニュアル](http://php.net/manual/en/book.curl.php)を見て、次に例を確認してください - [例えば](http://stackoverflow.com/質問/ 15203310/how-to-use-curl-in-facebook-graph-api-request) – DFriend

答えて

0

あなたはquickstart pageの外観を持つようにしたいことがあります。

use GuzzleHttp\Client; 

$client = new Client([ 
    // Base URI is used with relative requests 
    'base_uri' => 'http://httpbin.org', 
    // You can set any number of default request options. 
    'timeout' => 2.0, 
]); 


// Create a client with a base URI 
$client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']); 
// Send a request to https://foo.com/api/test 
$response = $client->request('GET', 'test'); 
// Send a request to https://foo.com/root 
$response = $client->request('GET', '/root'); 
+0

私はGuzzleをcodeigniterに統合する方法を教えてください。 –

+0

@MohammadRaquib http://stackoverflow.com/a/30485490/4279419 – Polyakoff

0

チェックこのリンク:

https://github.com/rohitbh09/codeigniter-guzzle

$this->load->library('guzzle'); 

    # guzzle client define 
    $client  = new GuzzleHttp\Client(); 

    #This url define speific Target for guzzle 
    $url  = 'http://www.google.com'; 

    #guzzle 
    try { 
    # guzzle post request example with form parameter 
    $response = $client->request('POST', 
            $url, 
            [ 'form_params' 
             => [ 'processId' => '2' ] 
            ] 
           ); 
    #guzzle repose for future use 
    echo $response->getStatusCode(); // 200 
    echo $response->getReasonPhrase(); // OK 
    echo $response->getProtocolVersion(); // 1.1 
    echo $response->getBody(); 
    } catch (GuzzleHttp\Exception\BadResponseException $e) { 
    #guzzle repose for future use 
    $response = $e->getResponse(); 
    $responseBodyAsString = $response->getBody()->getContents(); 
    print_r($responseBodyAsString); 
    }