PHP code example of code-corner / api-bridge

1. Go to this page and download the library: Download code-corner/api-bridge library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

code-corner / api-bridge example snippets




odeCorner\APIBridge\services\facebook\FacebookClient;
use CodeCorner\APIBridge\services\maps\GoogleMapsClient;
use CodeCorner\APIBridge\services\x\X;

// Set API keys and tokens
X::setAuthToken('YOUR_TWITTER_BEARER_TOKEN');
FacebookClient::setAuthToken('YOUR_FACEBOOK_ACCESS_TOKEN');
GoogleMapsClient::setApiKey('YOUR_GOOGLE_MAPS_API_KEY');



odeCorner\APIBridge\services\x\X;

// Fetch user information
$userData = X::getUser('twitter');
print_r($userData);

// Fetch user tweets
$tweetsData = X::getTweets('USER_ID');
print_r($tweetsData);



odeCorner\APIBridge\services\facebook\FacebookClient;

// Fetch user information
$userData = FacebookClient::getUser('USER_ID');
print_r($userData);

// Fetch page posts
$pagePostsData = FacebookClient::getPagePosts('PAGE_ID');
print_r($pagePostsData);



odeCorner\APIBridge\services\maps\GoogleMapsClient;

// Fetch geocode information
$geocodeData = GoogleMapsClient::getGeocode('1600 Amphitheatre Parkway, Mountain View, CA');
print_r($geocodeData);

// Fetch distance information
$distanceData = GoogleMapsClient::getDistance('place_id:ChIJN1t_tDeuEmsRUsoyG83frY4', 'place_id:ChIJN1t_tDeuEmsRUsoyG83frY4');
print_r($distanceData);
bash
    vendor/bin/phpunit tests/ApiClientTest.php