<?php // Include Cex.io PHP API include_once "cexapi.class.php"; // Create API Object $api = new cexapi("username", "api_key", "api_secret_code"); // Test some API Methods echo "Ticker:<pre>", json_encode($api->ticker()), "</pre>"; echo "Order Book:<pre>", json_encode($api->order_book()), "</pre>"; echo "Balance:<pre>", json_encode($api->balance()), "</pre>"; echo "Open Orders:<pre>", json_encode($api->open_orders()), "</pre>";
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Getting the price from Cex.io require_once "cexapi.class.php"; $username = "******"; $api_key = "api_key"; $api_secret = "api_secret"; $api = new cexapi($username, $api_key, $api_secret); $tick = $api->ticker("GHS/BTC"); $price = $tick["last"]; // Tweeting part of the script require_once "tmhOAuth.php"; $consumerKey = "consumerKey"; $consumerSecret = "consumerSecret"; $oAuthToken = "oAuthToken"; $oAuthSecret = "oAuthSecret"; $tmhOAuth = new tmhOAuth(array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'token' => $oAuthToken, 'secret' => $oAuthSecret)); $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => "The price of GHS/BTC on Cex.io is now {$price}")); if ($tmhOAuth->response['code'] != 200) { //Unsuccessful post, printing error message print_r(htmlentities($tmhOAuth->response['response'])); }