Jump to content

Search the Community

Showing results for tags 'api'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 8 results

  1. 0 What is the best way to store this data coming from the api into a csv file to later put into the db. Output: rank, level, xp, rank, level, xp, etc. This api produces about 60 rows of data per name ran and x that by about roughly 300 names that equals a lot of data. Pretty much with my current code I am pretty much creating a endless loop almost that would take a long time to execute so updating said data would be a nightmare i would think. Is there a way to accomplish the same thing without the loop or I am not sure how to go about this. My current code is a mess that much I know I am gonna be told. This code works, just not efficiently. I am thinking there may be a better way to do this. $query = $conn->prepare("SELECT name FROM users LIMIT 1"); $query->execute(); while($row = $query->fetch(PDO::FETCH_ASSOC)){ $name = $row['name']; $url = 'https://secure.runescape.com/m=hiscore/index_lite.ws?player='. $name . '';//api that the csv data is coming from $highscores = file_get_contents($url); $fields = array("Name", "Rank", "Level", "Xp");//this is to add the headers // for the csv files $implode1 = implode($fields, ",");//turn into csv format, not sure this is //even needed $implode1 .= "\n";/*this is to add a line break so that the explode below will properly put it into its own element*/ //otherwise data starts joining togather $extra_data = array("$name");/*This is to add the name that the data pertains too*/ $implode2 = implode($extra_data, ",");//turn into csv format $highscores = $implode1 . $implode2 . $highscores;//join as one array $highscores = explode("\n", $highscores);//turn each csv into an element of //its own element a bunch of unsets to remove unwanted data. Omitted them to condense the code $i = 1; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="name.csv"'); $data = $highscores; $fp = fopen('highscores/' . $name . '.csv', 'wb'); foreach ( $data as $line ) { $val = explode(",", $line); fputcsv($fp, $val); } fclose($fp); The pdo part I was gonna include but the way I have it setup now wouldn't work. I was thinking that I would use mysql's LOAD DATA INFILE to insert the csv data to database. The end goal here is to be able to search for player stats and to use said data to keep track of xp earned during a xp competition. I PRAY that i have included enough info... I would really appreciate any feedback if possible.
  2. Hi everyone. I'm very new into self learning programming. Presently I'm trying to develop a simple basic Robot that would only Place a Market Order every seconds and it will cancel the Order every followed seconds. Using the following library: https://docs.b2bx.exchange/en/_docs/api-reference.html#private-api It would place Trade Order at a ( Price = ex.com api * Binance api Aggregate Trades Price) I have already wrote the api to call for xe.com exchange rate with php <?php $auth = base64_encode("username:password"); $context = stream_context_create([ "http" => [ "header" => "Authorization: Basic $auth" ] ]); $homepage = file_get_contents("https://xecdapi.xe.com/v1/convert_from?to=NGN&amount=1.195", false, $context ); $json = json_decode($homepage, TRUE); foreach ($json as $k=>$to){ echo $k; // etc }; ?> And also for the Binance Aggregate Price in JavaScript <script> var burl = "https://api3.binance.com"; var query = '/api/v3/aggTrades'; query += '?symbol=BTCUSDT'; var url = burl + query; var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',url,true); ourRequest.onload = function(){ console.log(ourRequest.responseText); } ourRequest.send(); </script> My problem is how to handle these two api responds and also the functions to use them to place a trade and cancel it. Please help me out. Thanks in advance on any help.
  3. I've got a bit of a strange one here, Ive got posted data that seems to be reaching the server, but isn't available to the post array. I am posting data from an API to my server which is a codeigniter install. On the server I am simply collecting the posted data and dumping, so that I can see whats coming in. Here's the code in the controller to dump the posted data (simple stuff) : $data = array ( 'email' => $this->input->post('email'), 'password' => $this->input->post('password') ); var_dump($data); And when I use postman to test this, it works and I get this returned, which is what I expect, and tells me its not anything on the server that is preventing the posted data from being available: array(2) { ["email"]=> string(5) "alans" ["password"]=> string(4) "pass" } So all good! NOW When trying this from my API, the variables are empty, even though they are being posted to the server, when inspecting the the network via the browser console. I have added an image from the browser console, which clearly shows the data being posted as Form Data and the content type: application/x-www-form-urlencoded. (note: I have added the vars to the query string, headers and Form data, none of them are available from the server) SO, my question is, how is this possible. What could possibly cause the data to somehow go astray? Can you think of anything that would prevent the data being available, bearing in mind using the same variables, posting to the same URL and the same content type via postman. the data arrives? Any help with this would be very much appreciated as after about 15 hours trying everything I could think of I am at a loss. Cheers!
  4. I am using this API https://github.com/blocktrail/blocktrail-sdk-php. I am suppose to add this to top of my directory where I want to initialize the API. require 'vendor/autoload.php'; use Blocktrail\SDK\BlocktrailSDK; But the second line gives me an error. use Blocktrail\SDK\BlocktrailSDK; Parse error: syntax error, unexpected 'use' (T_USE) in C:\xampp\htdocs\site\templates\header.php on line 12 Is the "use" a correct syntax for php? Why is it giving me an error?
  5. "status": "success", "data": { "network": "DOGE", "prices": [ { "price": "0.00003556", "price_base": "LTC", "exchange": "cryptsy", "time": 1401185325 } ] } I know I can access the top value like this. echo $access->status; But how do I access the sub values underneath? The ones in "data"?
  6. im working with instagrams api and im not sure what to do next ... i so far have there access_token , but i dont know how to get the rest of the users information. the code below is given to me by instagram to retrieve the users information but i dont know what language to use it with , i have tried php but i dont know what to do with it ? please help thank you i have the access token , client id , client secret , and redirect uri. but do i change the CODE to a variable for the token ? curl \-F 'client_id=CLIENT-ID' \ -F 'client_secret=CLIENT-SECRET' \ -F 'grant_type=authorization_code' \ -F 'redirect_uri=YOUR-REDIRECT-URI' \ -F 'code=CODE' \https://api.instagram.com/oauth/access_token
  7. phphelpme


    alright , do you know how to get the section from the url , the token part and turn that into a variable ? example would be like this they instert the url here <form action="list.php" method="post"> <input name="token" type="text" style="width:200px;"/> <input type="submit" class="btn btn btn-info btn-mini" value="Login" /> </form> and then on list.php it seperates the token and makes it a variable the url looks like this http://localhost/instalike/code.php#access_token=263222910.4d15ef2.0b42098ba3b845b9940af5b46i just need the access_token i just need the access_token each access token will be different
  8. Hello there.. I have a problem when loading comment from my database.. Here are working scripts which does not query the message/comment from database.. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "responder"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //query the user table $sql = "SELECT * FROM user"; $result = $conn->query($sql); //get comment from array $comment = $_GET['comment'] + 1; //I want to replace below array comment with my database comment $ar = array( "Hello there.", "How are you?" ); require_once("facebook.php"); $config = array(); $config['appId'] = 'myapp'; $config['secret'] = 'mysecret'; $config['fileUpload'] = false; $fb = new Facebook($config); if ($result->num_rows > 0) { foreach ($result as $key) { $params = array( //long-live-token "access_token" => $key['offense_token'], //comment //need to replace this from database "message" => $ar[$comment], ); if($comment<10) { try { $ret = $fb->api('/my-comment-id/comments', 'POST', $params); echo 'Successfully posted to Facebook'; sleep(5); header('Location: set-comment.php?comment='.$comment); } catch(Exception $e) { echo $e->getMessage(); } } else{ echo "done"."<br>"; } } } ?> Above scripts working fine without querying from my database So my issues now, how do I query and loop each comment from database? Here my comment/message table.. TQ
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.