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

  1. I have code where I'm simply calling an API and I've converted it to loop the call so that I can call it with three different argument values. This is because the API is structured where it can accept one value for that argument at a time, but I need to compare the results of the three calls and I think the best way is to build a single array from the responses by either pushing a value if it exists or pushing the whole index if not. Think of it like the API response can give me data that can be as much as 400 products that are sold across 3 stores. All 400 may be sold in one store, but maybe only 120 in another and 100 in the third. I need my array to be all 400 products but I'll want to have an array within that holds the stores for the given product. Code: $IdentifierTest = 1472; $arguments = ['store 1', 'store 2', 'store 3']; $TestApi = app(TestApi::class); $newArray = array(); foreach($arguments as $argument){ $testResponse = $TestApi->getData($IdentifierTest, $argument); $Data = $testResponse->getResult()->getData(); // get the final results of call //check if array empty, and if so, push all records // if not empty, start checking 'id' against existing array records. If match, push stores. If not, add record to array } $this->makeFile($IdentifierTest, $Data); An example of the response is: array:426 [▼ 0 => prices {#2698 ▼ #container: array:11 [▼ "prd" => 2380 "id" => "173489" "price" => "65.00" ] } The issue is that specific example only shows up when calling the API with 'store 1' and 'store 2' as the argument, but not 'store 3'. What I'd like to do is call the API with each argument and create a new array with a ```stores``` index that pushes the store number if the id exists in the call, like so: array:426 [▼ 0 => prices {#2698 ▼ #container: array:11 [▼ "prd" => 2380 "id" => "173489" "price" => "65.00" stores: array[ 'store 1', 'store 2' ] ] } So when it's called with 'store 1' I would push the response into an array with 'store 1' as the value in 'stores', then on 'store 2' I would take the response and first check to see if the id exists in the array I've made. If it exists, I'll add 'store 2' to the 'stores' and if not I'll make a new index in the array. Basically, if product (id) 178293 is sold in all three stores then that means it would come back in all 3 API response calls and would end up being a single record in this new array with ```stores['store 1', 'store 2', 'store 3']``` How can I create a new array from this where I push only the stores if the id exists in the API call while keeping the current structure?
  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. 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.
  4. 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!
  5. 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?
  6. "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"?
  7. Hi I have a question about API keys and security. I am building a mobile app (learning) and will be using a PHP/MySQL JSON Rest API (designed myself) and I am new to APIs in general so some best practices would be appreciated if you have any? My real question is to do with securing these APIs. For example I was thinking of using user name and password that the user logs into the application with to be send over HTTPS for each request to validate the user is authorised and authenticated. However I have read that I should also be using API keys, so how would I integrate this in? Would each user have their own unique API key or would each system that uses this API have a unique key? If its each user that has their own key would I send all three pieces of data with the request (API Key, username and password). Any advice would be great. Thanks
  8. Trying to retrieve information from an API and display it in a table. <form action="dublinbus.php" method="get"> <h2>Current Dublin Bus Times.</h2> <b>Stop Number: </b><input type="number" name="stopid"></br></br> <input type="submit"> </form> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <?php $stopID = $_GET['stopid']; $url = "https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=" . $_GET['stopid'] . "&format=json"; // Process the JSON and check for errors $json = file_get_contents($url); $array = json_decode($json,true); if ($stopID != $array["stopid"]) { // Get the values for $errorCode and $errorMessage $errorCode = $array["errorcode"]; $errorMessage = $array["errormessage"]; echo "Error: "; echo $errorCode; echo $errorMessage; } else { // Get the values $duetime = $array["duetime"]; $destination = $array["destination"]; $route = $array["route"]; echo " <table>"; echo " <th>Stop Number</th><th>Route</th><th>Due Time</th><th>Destination</th>"; echo " <tr><td>" . $stopID . "</td><td>" . $route . "</td><td>" . $duetime . "</td><td>" . $destination . "</td></tr>"; echo "</table>"; } ?>
  9. 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
  10. Hello everyone.. I have a question to delete comment based from user-id itself. I use PHP SDK to delete any comment to my facebook page and it was success as long as I specify the comment-id.. Below are my codes to delete a comment from comment-id $request = new FacebookRequest( $session, 'DELETE', '/{comment-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); Is it possible to delete comment based on user-id itself? I know that I just need to query the graph api to get the comment-id from A but each comment have different id`s so its hard to query the comment-id everytime.. For example: A, B, and C comment to my facebook post and I want to delete the comment where the user-id is from A? So, if the api scan and found out that A is commenting to my post, it will be deleted instead deleting B and C I really appreciate for any help from you guys.. Thanks
  11. Hi guys, I am having a little trouble getting my head around how to tackle an issue. I am working with an API :- https://www.photoshelter.com/developer/index/endpoints/public Connecting up to it no problem and getting the information via cURL is also no bother. The point is I am needing to loop through galleries to retrieve 400 gallery IDs so I can pass in the data I need so for example I execute my first cURL response which gives me all the gallery IDs from here :- /psapi/v3/collection/root/children Now then I need to run a foreach loop to get each gallery ID to pass to :- /psapi/v3/gallery/{gallery_id} /psapi/v3/gallery/{gallery_id}/key_image Now the problem is I am having to use cURL to get the JSON data from here too and then finally the last one :- /psapi/v3/gallery/{gallery_id}/images/{image_id} To get the gallery featured image. Now the first cURL works fine but when I introduce the others in foreach loops it cripples it on loading time, but looking through of course it would as its excuting cURL a ridiculous amount of times. Is there a better way of tackling an issue like this as I feel cURL and file_get_contents is the wrong way going about this. Normally it's one execution and I get all the data I have never worked with something like this before. I would show my code but I feel it is unnecessary at this point on the grounds of I do not think this is the most productive way of even looking at this Currently the only thing I can think of is creating a query string to execute via a CRON job that would execute twice a day to check through the galleries API at Photoshelter and add everything to a database that I need. Any information would be greatly appreciated Thanks in advance Jamie
  12. I am looking to do something like this. Showing multiple locations of a business on Google Maps. Living Social has it and so does Groupon. https://www.livingsocial.com/ca/cities/83-ottawa/deals/1542906-basic-training-style-boot-camp?append_ref_code=home_whats_new I know it can be done manually but since it's a user based website, how would the user(business)'s added locations correspond with the Google Maps? Can you point me in the right direction?
  13. Hello, I have an Internet Radio station and I use Shoutcast. I have a function that allows me to grab the song and artist information such as Del Amitri - Roll To Me and show it on my website, and automatically changing when the songs change. I show the now playing, and last three songs. I'm wondering How I can get it to also pull in album artwork from Last.FM or Amazon such as this website: BIG 106.5 - Dayton's 70s & 80s Hits (move over the black bar and drop down). You will be able to see something such that I would want to accomplish. Not sure if this merely Javascript, or if there's also PHP.. but then again, I'd think Javascript for it to automatically change when a new song plays. Here is the file I currently have setup...which pulls the information from my shoutcast stream. I would love to incorporate album art from Amazon and/or an internal database that I have setup.. Here is what the file currently looks like. I also have stuff commented out for which I am not using ATTM. It pulls the song like artist - title <!--<html> <head>--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script> <script src="http://wlqtdb.com/wayne/pollstation.js" type="text/javascript"></script> <!--</head> <body>--> Now Playing on WLQT-DB: <!--<div id="currentsong"> </div>--> <span id="currentsong"></span> Recently Played: <!--<table> <tr><th>Recently Played Songs</th></tr> <tr><td><img id='prevsong1' alt=""><span id="prevsong1"></span></td></tr> <tr><td><span id="prevsong2"></span></td></tr> <tr><td><span id="prevsong3"></span></td></tr>--> <span id="prevsong1"></span> <span id="prevsong2"></span> <span id="prevsong3"></span> <!--<tr><td><span id="prevsong4"></span></td></tr> <tr><td><span id="prevsong5"></span></td></tr> <tr><td><span id="prevsong6"></span></td></tr> <tr><td><span id="prevsong7"></span></td></tr> <tr><td><span id="prevsong8"></span></td></tr> <tr><td><span id="prevsong9"></span></td></tr> <tr><td><span id="prevsong10"></span></td></tr>--> <!-- </table> Testing: <? echo "$currentsong"; ?> </body> </html>--> Any help would be greatly appreciated. As you can see with this result, I do the Current playing song, then it does the last 3 songs. Thanks
  14. I get funny result from my * echo $item['text']; * I do get the strings I intend to. Eg. I would like to have or sholud get the result: /Barrafina Exceptional cooking here. Such simple but amazing dishes. Highly recommend the crab croquettes, lambs kidneys, skewers and the brain. Sherries are also superb here. Matt Ta-Min/ But instead I get /Barrafina ee Exceptional cooking here. Such simple but amazing dishes. Highly recommend the crab croquettes, lambs kidneys, skewers and the brain. Sherries are also superb here. 5 5 E Eu uh h Matt Ta-Min / What did I do wrong? here is the code: If you have time and energy to look the JSON you will see from where eg.5 5 E Eu uh h.. comes. I appreciate any help. This is too strange for me. $json_results = json_decode($results,true); //var_dump($json_results); $items0 = $json_results['response']['groups']['0']['items']['0']; $items1 = $json_results['response']['groups']['0']['items']['0']['tips']; $items2 = $json_results['response']['groups']['0']['items']['0']['tips']['0']; //<div style="align:center;"> foreach ( $items0+$items1 as $item){ echo '<li>'; echo $item['name']; echo $item['text']; } foreach ( $items2 as $item){ print $item['firstName']; print '&nbsp'; print $item['lastName']; } Here is encode JSON array(2) { ["meta"]=> array(2) { ["code"]=> int(200) ["requestId"]=> string(24) "55fb1f91498e70ad2e246eed" } ["response"]=> array(10) { ["suggestedFilters"]=> array(2) { ["header"]=> string(12) "Tap to show:" ["filters"]=> array(2) { [0]=> array(2) { ["name"]=> string(13) "With specials" ["key"]=> string( "specials" } [1]=> array(2) { ["name"]=> string( "Open now" ["key"]=> string(7) "openNow" } } } ["geocode"]=> array( { ["what"]=> string(0) "" ["where"]=> string(6) "london" ["center"]=> array(2) { ["lat"]=> float(51.50853) ["lng"]=> float(-0.12574) } ["displayString"]=> string(38) "London, Greater London, United Kingdom" ["cc"]=> string(2) "GB" ["geometry"]=> array(1) { ["bounds"]=> array(2) { ["ne"]=> array(2) { ["lat"]=> float(51.691643999656) ["lng"]=> float(0.33418999705203) } ["sw"]=> array(2) { ["lat"]=> float(51.284674044171) ["lng"]=> float(-0.50855792793694) } } } ["slug"]=> string(6) "london" ["longId"]=> string(17) "72057594040571679" } ["warning"]=> array(1) { ["text"]=> string(114) "There aren't a lot of results near you. Try something more general, reset your filters, or expand the search area." } ["headerLocation"]=> string(6) "London" ["headerFullLocation"]=> string(6) "London" ["headerLocationGranularity"]=> string(4) "city" ["query"]=> string(4) "food" ["totalResults"]=> int(246) ["suggestedBounds"]=> array(2) { ["ne"]=> array(2) { ["lat"]=> float(51.510800358799) ["lng"]=> float(-0.12174369837641) } ["sw"]=> array(2) { ["lat"]=> float(51.508100699014) ["lng"]=> float(-0.13015278468604) } } ["groups"]=> array(1) { [0]=> array(3) { ["type"]=> string(18) "Recommended Places" ["name"]=> string(11) "recommended" ["items"]=> array(1) { [0]=> array(4) { ["reasons"]=> array(2) { ["count"]=> int(0) ["items"]=> array(1) { [0]=> array(3) { ["summary"]=> string(20) "This spot is popular" ["type"]=> string(7) "general" ["reasonName"]=> string(23) "globalInteractionReason" } } } ["venue"]=> array(17) { ["id"]=> string(24) "53bab96d498e7e355fb53d6c" ["name"]=> string(9) "Barrafina" ["contact"]=> array(6) { ["phone"]=> string(13) "+442074401456" ["formattedPhone"]=> string(16) "+44 20 7440 1456" ["twitter"]=> string(13) "barrafinaadst" ["facebook"]=> string(15) "705351912878392" ["facebookUsername"]=> string(23) "BarrafinaAdelaideStreet" ["facebookName"]=> string(25) "Barrafina Adelaide Street" } ["location"]=> array(10) { ["address"]=> string(14) "10 Adelaide St" ["crossStreet"]=> string(13) "William IV St" ["lat"]=> float(51.509450528906) ["lng"]=> float(-0.12594824153122) ["postalCode"]=> string( "WC2N 4HZ" ["cc"]=> string(2) "GB" ["city"]=> string(6) "London" ["state"]=> string(14) "Greater London" ["country"]=> string(14) "United Kingdom" ["formattedAddress"]=> array(5) { [0]=> string(30) "10 Adelaide St (William IV St)" [1]=> string(6) "London" [2]=> string(14) "Greater London" [3]=> string( "WC2N 4HZ" [4]=> string(14) "United Kingdom" } } ["categories"]=> array(1) { [0]=> array(6) { ["id"]=> string(24) "4bf58dd8d48988d150941735" ["name"]=> string(18) "Spanish Restaurant" ["pluralName"]=> string(19) "Spanish Restaurants" ["shortName"]=> string(7) "Spanish" ["icon"]=> array(2) { ["prefix"]=> string(52) "https://ss3.4sqi.net/img/categories_v2/food/spanish_" ["suffix"]=> string(4) ".png" } ["primary"]=> bool(true) } } ["verified"]=> bool(false) ["stats"]=> array(3) { ["checkinsCount"]=> int(357) ["usersCount"]=> int(278) ["tipCount"]=> int(26) } ["url"]=> string(22) "http://barrafina.co.uk" ["price"]=> array(3) { ["tier"]=> int(2) ["message"]=> string( "Moderate" ["currency"]=> string(2) "£" } ["rating"]=> float(9) ["ratingColor"]=> string(6) "00B551" ["ratingSignals"]=> int(80) ["allowMenuUrlEdit"]=> bool(true) ["hours"]=> array(2) { ["status"]=> string(19) "Open until 11:00 PM" ["isOpen"]=> bool(true) } ["specials"]=> array(2) { ["count"]=> int(0) ["items"]=> array(0) { } } ["photos"]=> array(2) { ["count"]=> int(31) ["groups"]=> array(0) { } } ["hereNow"]=> array(3) { ["count"]=> int(0) ["summary"]=> string(11) "Nobody here" ["groups"]=> array(0) { } } } ["tips"]=> array(1) { [0]=> array(9) { ["id"]=> string(24) "55db9142498ede18f5b31b81" ["createdAt"]=> int(1440452930) ["text"]=> string(164) "Exceptional cooking here. Such simple but amazing dishes. Highly recommend the crab croquettes, lambs kidneys, skewers and the brain. Sherries are also superb here." ["type"]=> string(4) "user" ["canonicalUrl"]=> string(52) "https://foursquare.com/item/55db9142498ede18f5b31b81" ["likes"]=> array(3) { ["count"]=> int(2) ["groups"]=> array(0) { } ["summary"]=> string(7) "2 likes" } ["logView"]=> bool(true) ["todo"]=> array(1) { ["count"]=> int(0) } ["user"]=> array(5) { ["id"]=> string( "98683884" ["firstName"]=> string(4) "Matt" ["lastName"]=> string(6) "Ta-Min" ["gender"]=> string(4) "male" ["photo"]=> array(2) { ["prefix"]=> string(31) "https://irs1.4sqi.net/img/user/" ["suffix"]=> string(30) "/98683884-1MJ0OTISTPZWSBRJ.jpg" } } } } ["referralId"]=> string(30) "e-3-53bab96d498e7e355fb53d6c-0" } } } } } } Here is JSON {"meta":{"code":200,"requestId":"55fbde58498e7fdbd12f8fb2"},"response":{"suggestedFilters":{"header":"Tap to show:","filters":[{"name":"With specials","key":"specials"},{"name":"Open now","key":"openNow"}]},"geocode":{"what":"","where":"london","center":{"lat":51.50853,"lng":-0.12574},"displayString":"London, Greater London, United Kingdom","cc":"GB","geometry":{"bounds":{"ne":{"lat":51.691643999655895,"lng":0.33418999705203406},"sw":{"lat":51.28467404417054,"lng":-0.5085579279369435}}},"slug":"london","longId":"72057594040571679"},"warning":{"text":"There aren't a lot of results near you. Try something more general, reset your filters, or expand the search area."},"headerLocation":"London","headerFullLocation":"London","headerLocationGranularity":"city","query":"food","totalResults":246,"suggestedBounds":{"ne":{"lat":51.5108003587992,"lng":-0.12174369837640672},"sw":{"lat":51.50810069901375,"lng":-0.1301527846860385}},"groups":[{"type":"Recommended Places","name":"recommended","items":[{"reasons":{"count":0,"items":[{"summary":"This spot is popular","type":"general","reasonName":"globalInteractionReason"}]},"venue":{"id":"53bab96d498e7e355fb53d6c","name":"Barrafina","contact":{"phone":"+442074401456","formattedPhone":"+44 20 7440 1456","twitter":"barrafinaadst","facebook":"705351912878392","facebookUsername":"BarrafinaAdelaideStreet","facebookName":"Barrafina Adelaide Street"},"location":{"address":"10 Adelaide St","crossStreet":"William IV St","lat":51.50945052890648,"lng":-0.1259482415312226,"postalCode":"WC2N 4HZ","cc":"GB","city":"London","state":"Greater London","country":"United Kingdom","formattedAddress":["10 Adelaide St (William IV St)","London","Greater London","WC2N 4HZ","United Kingdom"]},"categories":[{"id":"4bf58dd8d48988d150941735","name":"Spanish Restaurant","pluralName":"Spanish Restaurants","shortName":"Spanish","icon":{"prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/spanish_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":357,"usersCount":278,"tipCount":26},"url":"http:\/\/barrafina.co.uk","rating":9.0,"ratingColor":"00B551","ratingSignals":80,"allowMenuUrlEdit":true,"hours":{"status":"Closed until Noon","isOpen":false},"specials":{"count":0,"items":[]},"photos":{"count":31,"groups":[]},"hereNow":{"count":0,"summary":"Nobody here","groups":[]}},"tips":[{"id":"55db9142498ede18f5b31b81","createdAt":1440452930,"text":"Exceptional cooking here. Such simple but amazing dishes. Highly recommend the crab croquettes, lambs kidneys, skewers and the brain. Sherries are also superb here.","type":"user","canonicalUrl":"https:\/\/foursquare.com\/item\/55db9142498ede18f5b31b81","likes":{"count":2,"groups":[],"summary":"2 likes"},"logView":true,"todo":{"count":0},"user":{"id":"98683884","firstName":"Matt","lastName":"Ta-Min","gender":"male","photo":{"prefix":"https:\/\/irs1.4sqi.net\/img\/user\/","suffix":"\/98683884-1MJ0OTISTPZWSBRJ.jpg"}}}],"referralId":"e-3-53bab96d498e7e355fb53d6c-0"}]}]}}
  15. Would like some thoughts about this autoloader for namespaces. Its loosely based on Zend Framework 2 using Composer. I wanted a simple loader for including my custom classes(ie DB connection, list and forms generations etc) in application modules. Autoloader works as expected so no error to debug, but looking more for improvements or gotcha's I'm not aware of. This is pseudo code, but the machinery is what's important. ./controller_script.php /* initializes Autoload with an array of namespace strings */ include 'init_autoloader.php'; /* from testspaces.php */ echo Testspaces\Autoload\Tsclass::printSomething(); // outputs This is a simple string. /* from globalspaces.php */ echo Globalspaces\Autoload\Omnipresent::imEverywhere(); //outputs This is a good hand. ./init_autoloader.php /** * initialize the autoloader for namespaces under the lib directory. * this script would be placed in each module where global classes * were required, ie DB connections, UI output(lists and forms) */ /* namespaces array, namespace file name matches first part before first backslash */ $nsarray = array( 'Globalspaces\Autoload\Omnipresent', 'Testspaces\Autoload\Tsclass', ); /* initialize the AutoloaderInit class */ $apath = __DIR__ . "/lib/autoload.php"; if (file_exists($apath)) { include $apath; $loaderObj = new AutoloaderInit($nsarray); $loaderObj->getLoader(); } else { echo "Missing autoload.php script, check file path: ".$apath."<br>"; } lib/autoload.php class AutoloaderInit { private static $loader; private static $nsnames; // indexed array of namespace strings defined in init_autoloader public function __construct($nsarray) { self::$nsnames = $nsarray; } /* * callback function called by spl_autoload_register * $class passed by reference */ public static function loadClassLoader($class) { if ($class) { $nameparts = explode('\\', $class); $filename = strtolower($nameparts[0]).".php"; require __DIR__ . DIRECTORY_SEPARATOR . $filename; } else { throw new Exception("loadClassLoader failed to include ".$filename); } } /* * interface method called from initializer * $params array $nsnames, array of namespace strings * $return void */ public static function getLoader() { //error_log("getLoader nsnames: ".var_dump(self::$nsnames)); if (self::$nsnames) { $cnt = count(self::$nsnames); for($i=0;$i<=$cnt;$i++) { if (null !== self::$loader) return self::$loader; spl_autoload_register(array('AutoloaderInit', 'loadClassLoader'), true, true); self::$loader = $loader = new self::$nsnames[$i]; // new instance of class } // close for loop spl_autoload_unregister(array('AutoloaderInit', 'loadClassLoader')); return $loader; } else { error_log("No namespaces provided to getLoader"); } } } lib/testspace.php namespace Testspaces\Autoload; /* a class defined in namespace */ class Tsclass { static function printSomething() { echo "This is a simple string.<br>"; } } lib/globalspaces.php namespace Globalspaces\Autoload; /* another class defined in namespace */ class Omnipresent { static function imEverywhere() { echo "This is a good hand.<br>"; } }
  16. I've created a php code that automatically pulls post that are assigned to a category (dailydose) from my wordpress site and creates a daily mailchimp campaign using a email template. I now want to be able to pull ads that are assiocated with each post. So I'm stuck on how I can make that happen please help!! functions.php //wp_schedule_event( 1428610800, 'hourly', 'daily_dose_mailer' ); //wp_unschedule_event( time(), 'hourly', 'daily_dose_mailer' ); //wp_clear_scheduled_hook( 'daily_dose_mailer' ); add_action( 'daily_dose_mailer', 'daily_doser' ); function daily_doser(){ $cur_day = date( "w", time()); $standard_order = array("1","2","3","4","5"); if($cur_day >= 1 && $cur_day <= 5){ require_once 'includes/mailchimp-mailchimp-api-php-190cf58000ee/src/Mailchimp.php'; //Get content $custom_query = new WP_Query(array('post_type'=>'post','posts_per_page'=>5,'cat'=>1279)); $content = array(); $std_count = 0; while($custom_query->have_posts()) : $custom_query->the_post(); $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); if(get_post_meta(get_the_ID(),"dd_order",true) != "") $content[get_post_meta(get_the_ID(),"dd_order",true)] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); else $content[$standard_order[$std_count]] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); $std_count++; endwhile; $content_with_html = ''; $count = 1; $ad_count = 0; if($cur_day == 1) $ad_order = array("4","5","6","7","8"); if($cur_day == 2) $ad_order = array("8","4","5","6","7"); if($cur_day == 3) $ad_order = array("7","8","4","5","6"); if($cur_day == 4) $ad_order = array("6","7","8","4","5"); if($cur_day == 5) $ad_order = array("5","6","7","8","4"); foreach($content as $cont){ if(function_exists("wp_template_ad")) { $ad = wp_template_ad($ad_order[$ad_count]); } if($count == 1){ $content_with_html .= ' <tr> <td> <table style="width: 600px; margin: 10px 0;" width="600px"> <tbody> <tr> <td style="padding: 0px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 26px; line-height: 28px; color: #03030B; letter-spacing: -.03em; text-decoration: none;">'.$content[strval($count)]["title"].'</a> <a href="'.$content[strval($count)]["link"].'" style="text-decoration: none;float:right;" target="_blank"><img src="'.$content[strval($count)]["image"].'" style="width: 250px; min-height: 165px;" width="250" width="250" /></a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 15px; line-height: 19px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 14px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> </tbody> </table> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; }else{ $content_with_html .= ' <tr> <td style="padding: 13px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 20px; line-height: 24px; color: #03030B; letter-spacing: -.03em; text-decoration: inherit;">'.$content[strval($count)]["title"].'</a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 12px; line-height: 18px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 11px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; } $count++; $ad_count++; } /*$content_with_html .= ' <tr align="center"> <td class="spacer"> '. wp_templol($ad_order[$ad_count]).'</td> </tr> ';*/ $MC = new Mailchimp('01a1ecf38bc12fdc975ff0c569945244-us1'); //Pseudo code //Grab the list that it will be sent to //lists/members (string apikey, string id, string status, struct opts) //Create markup of email - this also assigns the appropriate list //campaigns/create (string apikey, string type, struct options, struct content, struct segment_opts, struct type_opts) $retval = $MC->call('campaigns/create', array( "type"=>"regular", "options"=> array("list_id"=>"1924082bfe", "subject"=>"Your Daily Dose from DS News", "from_name"=>"DSNews", "from_email"=>"news@dsnews.com", "inline_css"=>true), "content"=> array("html"=>' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Your Daily Dose of DS News</title> </head> <body> <div align="left" style="text-align: left; font-size: 12px; font-family: Century Gothic,Georgia,Verdana; padding-bottom: 50px !important;"> <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; margin: 0px;" width="728"> <tbody> <tr> <td align="center" bgcolor="#fff" colspan="2" style="padding: 5px; text-align: center;"> Email not displaying correctly? <a href="*|ARCHIVE|*">Display this email in your browser</a></td> </tr> <tr> <td align="center" bgcolor="#000" colspan="2" style="text-align: center; background-color: #000;"> <img alt="" height="30" src="http://admin.dsnews.com/editor_images/image_19b6f173/column.gif" style="width: 15px; min-height: 30px;" width="15" width="15" /> <table align="center" bgcolor="#000000" border="0" cellpadding="0" cellspacing="10px" width="600"> <tbody> <tr align="center" style="width: 600px;"> <td align="center" bgcolor="#FFF" style="padding: 0 0px; font-size: 12px; text-transform: uppercase; text-align: left; font-weight: bold; color: #fe0000; background-color: #000; font-family: Arial, Helvetica, sans-serif;"> *|DATE:l, M j, Y|*</td> <td align="right" bgcolor="#8a8b8a" style="font-size: 12px; text-transform: uppercase; padding: 0 0px; text-align: right; font-weight: bold; color: #fff; background-color: #000;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247987c4a6efb818978c" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000; letter-spacing: .003em;" target="_blank">HOME</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24791b911a59d15e5063" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">CONTACT US</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f018cfa44911db10" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">MAGAZINE</a><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c6b1632e3f8df548" style="text-decoration: none; color: #000;" target="_blank"> </a>| <em><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479ac6f4a1f6d5178c8" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">SUBSCRIBE</a></em></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 600px; margin: 0px auto;"> <tbody> <tr> <td width="600"> <div align="center" style="text-align: center;"> </div> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b35fafb4d42723f5" style="text-decoration: none;" target="_blank"><img alt="DSNews.com | Daily Dose" height="109" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Daily-Dose.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 123px;" width="600" width="600" /></a></td> </tr> <tr> <td> <div align="center" style="text-align: center;"> </div> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> <tr> <td> <table style="width: 600px; margin: 0;"> <tbody> <tr> <td align="center" style="padding: 0px 0; text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24799b979aa344545f8a" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: none;"> DSNEWS.COM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479db831868790c2639" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">REOREDBOOK</a>| <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479d269f0e3591d670f" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -0.03em; text-decoration: inherit;">BLACK BOOK</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247903105127fafb9dbc" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FORCE</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247907d4c0d59b488676" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">GOVERNMENT FORUM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247905ea889cdfee43cf" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FIVE STAR CONFERENCE</a></td> </tr> </tbody> </table> </td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '.$content_with_html.' <tr> <td> </td> </tr> </tbody> </table> <table bgcolor="#f3f3f3" border="0" cellpadding="0" cellspacing="0" style="margin: 10px auto;" width="100%"> <tbody> <tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td colspan="2"> <table style="width: 600px; margin: 10px auto;"> <tbody> <tr> <td align="center" style="width: 200px; text-align: center; padding-right: 5px;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24793af4e6a183b3ef6f" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank"><img alt="DSNews" height="50" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/ds.jpg" width="50" /></a></td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" style="font-size: 9px; text-align: left; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="280"> <strong style="color: #67c7d3; font-weight: normal;">Corporate Offices</strong> | Phone: 800.856.8060<br /> 1909 Woodall Rodgers, Suite 300 Dallas, Texas 75201</td> <td align="center" style="font-size: 9px; text-align: right; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="320"> <strong style="color: #67c7d3; font-weight: normal;">Washington Bureau</strong> | Phone: 202.393.5511<br /> 1101 Pennsylvania Ave. NW, Suite 600 | Washington, D.C. 20004</td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td align="center" colspan="2" style="color: #8a8b8a; padding: 10px 0px; font-size: 7px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #252722; text-align: center;"> You are receiving this e-mail because you opted in at our Web site DSNews.com or attended a Five Star Conference. Copyright 2009 DS News. All rights reserved.<br /> <a href="*|UNSUB|*" style="text-decoration: none; color: #000000; " target="_blank">Unsubscribe.</a> <span style="line-height: 11.199999809265137px;">*|EMAIL|*<span style="font-size: 7px; line-height: 1.6em;"> from this list.</span></span></td> </tr> <tr> <td align="center" colspan="2"> <table style="width: 600px;"> <tbody> <tr> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247963cf5f9844f5a817" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">DSNews.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c36851c1fe0a7a08" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">REORedBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f47338dd7e641363" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">BlackBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b6f3467ce75a656b" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">TheFiveStar.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24790cdf2f599aba04c2" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">FORCE</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> <br /> </body> </html> ') ) ); //Send it out //campaigns/send-test (string apikey, string cid, array test_emails, string send_type) - this will be replace by normal send // echo $retval; } }
  17. Hi.. I really need help. I'm completely stuck and waaaay out of my depth here. I don't even know where to begin. I am desperate to learn how to use existing API services - but I find the whole concept completely overwhelming. I can't even get something from a Google search because everything on this subject just goes over my head. I have created an account with tvrage.com and got an API key. With that, I can get a list, in XML, of all the current TV shows in the UK and the US. It starts like this; <currentshows> <country name="US"> <show> <showid>69</showid> <showname>Who Wants to Be a Millionaire (US)</showname> <showlink>http://tvrage.com/Who_Wants_to_Be_a_Millionaire_US</showlink> </show> <show> <showid>237</showid> <showname>Jack Van Impe</showname> <showlink>http://tvrage.com/jack-van-impe</showlink> </show> <show> <showid>286</showid> <showname>Figure It Out</showname> <showlink>http://tvrage.com/figure-it-out</showlink> </show> <show> <showid>548</showid> <showname>TNA Pay-Per-View</showname> <showlink>http://tvrage.com/TNA_Pay-Per-View</showlink> </show> <show> <showid>576</showid> <showname>WWE After Burn</showname> <showlink>http://tvrage.com/wwe-after-burn</showlink> </show> All I want, is to list this out on MY website... I am a complete beginner. I imagine I have to copy and paste the URL in to my code, right? A javascript link? But then, what after that? I have barely touched javascript or jquery as a developer. Can someone just give me some guidance on this please? It's really starting to stress me out :-(
  18. GoodWorld is an early-stage, venture-funded start-up changing the face of philanthropy through an innovative approach to online fundraising. Our technology allows you to donate without leaving social media, simply by writing #donate on any Facebook post or when you tweet at any of our partner charities. Job Description GoodWorld seeks an experienced PHP developer with a passion for elegant/functional code as well as doing good in the world. The ideal candidate will have experience leading a development team and with agile development methods. Responsibilities: - Determine operational feasibility by evaluating analysis, problem definition, requirements, solution development, and proposed solutions. - Document and demonstrates solutions by developing documentation, flowcharts, layouts, diagrams, charts, code comments and clear code. - Prepare and install solutions by determining and designing system specifications, standards, and programming. - Improve operations by conducting systems analysis - Obtain and license software by obtaining required information from vendors; recommending purchases; testing and approving products. - Collecting, analyzing, and summarizing development and service issues. - Develop software solutions by studying information needs, conferring with users, studying systems flow, data usage, work processes, and investigating problem areas Skills & Requirements Experience: - PHP - MySQL - PHPUnit or other testing framework - Ubuntu server administration - Twitter API and Facebook API integration Bonus, experience with: - Amazon Web Services - Continuous deployment - Laravel framework - Payment gateway integrations Location: Onsite strongly preferred, but open to remote employment Salary: $60-120K; a small equity allotment also possible If interested, email me at rasheen@nsphire.com
  19. We have a wordpress install with the plugin wp-job manager installed. https://wpjobmanager.com We add and manage jobs via YouRecruit but we want to update them to our wordpress database (wp-job manager) every time they're added, updated or we deleted. We also have a plugin/api module from YouRecruit which extends the wp job manager plugin and enables us to post and delete jobs to wp-job manager using xml. This is all the documentation I have on the API module from YouRecruit below and there are no settings in the back end of wordpress for you to fill in. Based on what I have read below I am assuming the plugin handles most of the processing but you still have to write your own PHP script and host it at 'http://www.yoursite.com/jobload/get_job.php' for example. At least this is what it says. I'm thinking were going to have to fetch the xml with simple_xml there is a brief code snipped in the documentation on doing this. I then don't know where to go from there or if this is the correct way to go about dealing with this issue. http://yourecruit.com/resources_public/wordpress_job_manager_api.php http://yourecruit.com/resources_public/own_site_posting.php Could anyone confirm if I am thinking along the right lines here. Thanks your advice is very much appreciated.
  20. I have created a system that uses an API to drop utility data into MSQL Server 2008. Once the data is in the db, a web app can query the data to create electric bills. Currently we are working with only one customer but are entertaining expansion and want to approach the growth from the best possible angle. Considering that all data is the same type of data but comes from different customers and sources, would it be best to maintain 1 database with all of the utility meter data streaming to it or would it be best to have a new data base with each customer? Also, assuming we keep it all in the same database, would it be best (assuming we are secure) to have all the individual customers data go to the same tables or have separate tables for separate customers. I'm pretty certain I know the answer but I'm a novice so that means nothing. Thank you for any help with this issue.
  21. Hey guys, I need some help with a simple script a friend wrote for me but isn't returning the correct values. I'm looking to get this script working but my PHP skills are abysmal and I can't for the life of me figure out whats the best way to do this. I've tried contacting my friend but he's moving cross-country so I'm hoping you guys can give me some advice. The script is supposed to return a total shipping price based on the weight of products that are passed to it via an API and the location of the visitor. There are a total of 3 different products (Product A, Product B, Product C) each with it's own weight in grams and it's own shipping rate. The script is needs to follow the following rules: When 1 product (either Product A, B, or C) is in the cart it returns the full fixed shipping price for either US or International Shipping based on $isInternational When 2 or more of Product A or B are added to the cart the full shipping is taken for the heaviest item and a fixed price is added for each additional item (Product and B each have their own fixed prices) When Product C is added to the cart it returns a fixed based on US or International (Product C ships separately and doesn't depend on the weight/prices of Product A or B) The product weights/prices are: Product A: Weight (grams): 250 Us Shipping for first instance: $6.00 International Shipping for first instance: $10.00 Each additional instance: $1.00 Product B: Weight (grams): 300 Us Shipping for first instance: $8.00 International Shipping for first instance: $11.00 Each additional instance: $2.50 Product C: Weight (grams): 120 Us Shipping for each instance: $8.00 International Shipping for each instance: $20.00 An example would be if the cart contained 2 of Product B, 1 of Product A, and 2 of Product C shipping to the US: The price would be 8+2.50+1+8+8=27.50 The script currently ignores the addition of more instances of the items and doesn't take into account US vs International: <? header('Content-Type: application/json'); $json = file_get_contents('php://input'); $request_body = json_decode($json, true); if (is_null($request_body) or !isset($request_body['eventName'])) { header('HTTP/1.1 400 Bad Request'); $response = array( "rates" => "" ); die(json_encode($response)); } switch ($request_body['eventName']) { case 'shippingrates.fetch': // ============= recieve data from cart ============== $country_code = $request_body["content"]["billingAddressCountry"]; $state_code = $request_body["content"]["billingAddressProvince"]; $isInternational = ($country_code != "US"); $quantity = 0; $maxWeight = 0; $cost = 0; $description = "International Shipping"; if($request_body["content"] && $request_body["content"]["items"]){ foreach ($request_body["content"]["items"] as $cart_item){ $quantity += $cart_item["quantity"]; if($cart_item["weight"] >= 300){ $cost += 2.50; } else if($cart_item["weight"] >= 200){ $cost += 1.0; } else if($cart_item >= 100){ $cost += ($isInternational)? 15.0 : 8.0; } if($cart_item["weight"] > $maxWeight){ $maxWeight = $cart_item["weight"]; } } } if($maxWeight >= 300) { $cost += ($isInternational) ? 11.0 : 8.0; $cost -= 2.50; } else if ($maxWeight >= 200) { $cost += ($isInternational) ? 10.0 : 6.0; $cost -= 1; } if($isInternational){ $description = "International Shipping"; } else { $description = "USPS Standard Shipping"; } // =========== return data to cart =============== $rates = array( array( "cost" => $cost, "description" => $description ), ); $response = array( "rates" => $rates ); header('HTTP/1.1 200 OK'); echo(json_encode($response)); break; default: header('HTTP/1.1 200 OK'); break; } ?> Thanks for any help you guys can give!
  22. This is the code im using to try to connect Empire Avenue API but i must be missing somthing here still trying to figure out all this Oauth stuff. <?php ?> <html> <head>Empire Traider2</head> <body> <form method="post" action="https://www.empireavenue.com/profile/developer/authorize?client_id=app_543abbac2ad99&response_type=code&state=request_access_token"> <input type="submit" value="Login" /> </form> </body> </html> Oauth.php <?php require('client.php'); require('GrantType/IGrantType.php'); require('GrantType/AuthorizationCode.php'); const CLIENT_ID = 'app_543abbac2ad99'; const CLIENT_SECRET = '1ee4b7f5d702d2c7e64523daf4d107b3dd82a0a787f117986d84f'; const REDIRECT_URI = 'https://yousearch.mobi/OAuth2/oauth.php'; const AUTHORIZATION_ENDPOINT = 'http://www.empireavenue.com/profile/developer/authorize'; const TOKEN_ENDPOINT = 'https://api.empireavenue.com/oauth/token'; $client = new OAuth2\Client(CLIENT_ID, CLIENT_SECRET); if (!isset($_GET['code'])) { $auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI); header('Location: ' . $auth_url); die('Redirect'); } else { $params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI); $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params); parse_str($response['result'], $info); $client->setAccessToken($info['access_token']); $response = $client->fetch('https://api.empireavenue.com/profile/info'); echo $response; echo 'test'; } ?> Here are the docs http://www.empireave...elopers/apidocs yousearch.mobi
  23. I am a noob in api so please bear with me. I tried google searching for 1 hour but I can't understand anything from the results. Currently, I have an API in kimono with the given example data : { "name": "Summoners-Details", "count": 31, "frequency": "On demand", "version": 7, "newdata": false, "lastrunstatus": "success", "thisversionrun": "Tue Sep 02 2014 02:34:07 GMT+0000 (UTC)", "lastsuccess": "Tue Sep 02 2014 02:34:07 GMT+0000 (UTC)", "stats": { "retriedUrls": [], "failedUrls": [], "successful": 1, "rows": 31, "retried": 0, "failed": 0, "duration": 1894 }, "results": { "rank": [ { "division": "Wukong's Lancers Silver-tier II" } ] } } Here is the php code I am trying to use to get the division data, but I am getting nothing! : <?php $request = "https://www.kimonolabs.com/api/c6qj1oc?apikey=xxxxxxxxxxxxxxxxxx"; $response = file_get_contents($request); $results = json_decode($response, TRUE); $division = $results->{'results'}->{'rank'}->{'division'}; echo $division; ?> What am I doing wrong here??
  24. Hi Guys and Girls, I'm having a bit of a hard time getting some pagination working. I have a script using CURL getting JSON results via a HTTP API. This is also used in a Wordpress Installation. The API call has a maximum of 50 records returned but allows pagination. What I can't seem to get right is actually getting this to work. Below is the code that I'm using: <?php //functions relating to wordpress go here: //---------------------------------------- $bg_colors = array('green', 'orange', 'blue', 'yellow', 'red', 'black'); //---------------------------------------- //End functions relating to wordpress // Start PetRescue PHP/API Code //---------------------------------------- // Open CuRL/JSON Stuff $ch = curl_init(); $category=$_GET['category']; $url="http://www.xxx.com.au/api/listings?token=xxxtokenxxx&group_id=xxx&species=".$category; curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept: application/json', 'X-some-API-Key: xxxtokenxxx', )); $json = json_decode(curl_exec($ch), true); //Pagination stuffs if($_GET['page']) { $page=substr($_GET['page'],1); echo 'page'.$page; } // Functions relating to the Echo Code foreach($json['listings'] as $listing) { $short_personality=substr($listing['personality'],0,500); $peturl="http://xxx.org.au/pet-info/?petid=".$listing['id']; $medium_photo=$listing['photos'][0]['large_340']; $gallery_first=$listing['photos'][0]['xlarge_900']; $gender_class=strtolower($listing['gender']); $breed_class=strtolower($listing['species']); $name=($listing['name']); $unique_gallery_name="lightbox['.$inc.']"; $inc++; foreach($listing['photos'] as $photosthumb) { $photo_thumb_large=$photosthumb["xlarge_900"]; $photo_thumb_hidden=$photosthumb["xlarge_340"]; } $rand_background = $bg_colors[array_rand($bg_colors)]; // General IF/AND/ELSE Statements to refine the Echo Output if($listing['photos'] == null) { $medium_photo="http://xxx.org.au/wp-content/themes/xxx/images/photo_coming_soon.png"; } if($listing['desexed'] == "Yes") { $desexed="yes"; } else { $desexed="no"; } if($listing['vaccinated'] == "Yes") { $vaccinated="yes"; } else { $vaccinated="no"; } if($listing['wormed'] == "Yes") { $wormed="yes"; } elseif($listing['wormed'] == "No") { $wormed="no"; } else { $wormed="no"; } if($listing['heart_worm_treated'] == "Yes") { $heart_worm_tested="yes"; } elseif($listing['heart_worm_treated'] == "No") { $heart_worm_tested="no"; } else { $heart_worm_tested="no"; } if($listing['species'] == "Dog") { $adoption_enquiry_link="http://xxx.org.au/pre-adoption-form-dogs/?dog_name=$name"; $hwt="list-$heart_worm_tested"; } elseif($listing['species'] == "Cat") { $adoption_enquiry_link="http://xxx.org.au/pre-adoption-form-cats/?cat_name=$name"; $hwt="list-hwt-hidden"; } // Echo the output echo'<div class="animal"> <div class="animal-image"> <a class="size-thumbnail thickbox" rel="'.$unique_gallery_name.'" href="'.$gallery_first.'"> <img src="'.$medium_photo.'" class="image-with-border" alt=""> <div class="border" style="width: 340px; height: 340px;"> <div class="open"></div> </div> </a> <div class="item-title-bg '.$rand_background.'"> <h2 class="entry-title"> '.$listing['name'].'</h2> <div class="animal-adopt-button"> <a href="'.$adoption_enquiry_link.'" style="background-color: #575757; border-color: #494949; background-position:5px 0;" class="button medium"> Enquire about '.$name.'</a> </div> </div> </div> <div class="animal-thumbnail hidden"> <a class="lightbox" rel="'.$unique_gallery_name.'" href="'.$photo_thumb_large.'"> <img class="animal-thumbnail" src="'.$photo_thumb_hidden.'" > </a> </div> <div class="animal-content"> <div class="animal-left"> <ul class="animal-list"> <li class="list-sex-'.$gender_class.'">'.$listing['gender'].'</li> <li class="list-breed-'.$breed_class.'">'.$listing['breeds_display'].'</li> <li class="list-age">'.$listing['age'].'</li> <li class="list-fee">'.$listing['adoption_fee'].'</li> </ul> </div> <div class="animal-right"> <ul class="animal-list"> <li class="list-'.$desexed.'">Desexed?</li> <li class="list-'.$vaccinated.'">Vaccinated?</li> <li class="list-'.$wormed.'">Wormed?</li> <li class="'.$hwt.'">Heart Worm Tested?</li> </ul> </div> <div class="animal-full"> <ul class="animal-list"> <li class="list-description">'.$listing['personality'].'</li> </ul> </div></div> <div class="clearer"></div> </div> <div class="delimiter"></div>'; // Close the CURL } echo' <div class="pagination footer-pagination"> <nav class="pagination"> <div class="pages">'; for($i=1;$i<=$json['total_pages'];$i++) { $this_page=substr($_GET['page'],1); $active=""; if($i==$this_page) { $active="active"; } echo ' <span class="page'. $active.'"> <span class="number"> <a rel="prev" href="http://xxx.org.au/pet/?category=dog&page='.$i.'"> '.$i.'</a> </span> </span> </div> </nav> </div>'; curl_close($ch); } ?> This is a sample of the JSON results: {"listings":[{"adoption_fee":"$200 ","adoption_process":"For cats, please fill out our <a href=\"http://xxx.org.au/pre-adoption-form-cats/\">Pre-Adoption Questionnaire - Cats</a>.\r\n\r\nFor dogs, please fill out our <a href=\"http://xxx.org.au/pre-adoption-form-dogs/\">Pre-Adoption Questionnaire - Dogs</a>.\r\n\r\nFor more information on our Adoption Process, please visit this <a href=\"http://xxx.au/our-adoption-process/\">link</a>.\r\n\r\nPlease make sure that you are familiar with our <a href=\"http://xxx.org.au/adoption-agreement/\">Adoption Agreement</a> as it has recently changed.\r\n\r\nFor more information on any of our animals, please <a href=\"http://xxx.org.au/contact-us/\">Contact Us</a>.","age":"2 years 5 months","breeds":["Domestic Long Hair"],"breeds_display":"Domestic Long Hair","coat":"Long","contact_name":null,"contact_number":null,"contact_preferred_method":"Email","created_at":"30/1/2014 21:36","date_of_birth":"20/2/2012","desexed":true,"foster_needed":false,"gender":"Female","group":"xxx","heart_worm_treated":null,"id":273191,"interstate":false,"last_updated":"5/8/2014 12:20","medical_notes":"","microchip_number":"","mix":false,"multiple_animals":false,"name":"Helena HC13-394","personality":"Stunning Helena!\r\n\r\nThis beautiful girl is looking for a home that is fairly relaxed. She is not happy about sharing her current foster home with some bossy cats, she likes to be the princess of her realm.\r\n\r\nShe is very affectionate, and when it is quiet she will come and have a big smooch around our legs, and purr her pretty little purr. \r\n\r\nShe is somewhat timid to start with, but enjoys the company of people and once she trusts, she's a very special companion.\r\n\r\n","photos":[{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_cb61a_70x70.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_cb61a_130x130.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_cb61a_340x340.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_cb61a_900x900.jpg"},{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_7a7a7_70x70.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_7a7a7_130x130.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_7a7a7_340x340.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_7a7a7_900x900.jpg"},{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_8b90b_70x70.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_8b90b_130x130.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_8b90b_340x340.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/1/30/273191_8b90b_900x900.jpg"},{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_691df_70x70_96020.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_691df_130x130_96020.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_691df_340x340_96020.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_691df_900x900_96020.jpg"},{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_6d9da_70x70_d2d41.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_6d9da_130x130_d2d41.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_6d9da_340x340_d2d41.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/4/26/273191_6d9da_900x900_d2d41.jpg"},{"small_80":"http://xxx.com.au/uploads/pet_photos/2014/7/12/273191_f209f_70x70_982c6.jpg","medium_130":"http://xxx.com.au/uploads/pet_photos/2014/7/12/273191_f209f_130x130_982c6.jpg","large_340":"http://xxx.com.au/uploads/pet_photos/2014/7/12/273191_f209f_340x340_982c6.jpg","xlarge_900":"http://xxx.com.au/uploads/pet_photos/2014/7/12/273191_f209f_900x900_982c6.jpg"}],"senior":false,"size":null,"species":"Cat","state":"WA","vaccinated":"Yes","wormed":"Yes"}, And the pagination details are at the bottom of the JSON response: "page":"1","per_page":"50","total_pages":"6" The issue I get with all of this, is when calling the PHP file again, it's just returning the first page of results and not the second page. Any help would stop me from eating my own eyeballs, as I've been staring at this for hours! Cheers, Dave
  25. Hello everyone, I'm new here My website was working fine until a few days ago, Up until then my str_replace('s130x130', 's800x800') and str_replace('_s', '_o') solved the picture thing. Now the images are broken (or very small) and I can find no documentation on how to enlarge the pictures. Thus my question: how do I retrieve larger pictures from the Facebook PHP SDK? Code foreach($pagefeed['data'] as $post) { if ($post['type'] == 'status' || $post['type'] == 'link' || $post['type'] == 'photo') { if ($post['type'] == 'photo') { echo "<div class='col-md-6 col-sm-6'>"; echo "<div class='thumbnail'>"; echo "<img src=" . str_replace('s130x130', 's800x800', str_replace('_s', '_o', $post['picture'])) . " />"; echo "<div class='caption'>"; echo "<sup>Geplaatst op: " . date("d-m-Y, (strtotime($post['created_time']))) . "</sup>"; if (empty($post['message']) === false) { echo "<p><span class='glyphicon glyphicon-comment'></span> " . $post['message'] . "</p>";} echo "</div>"; echo "</div>"; echo "</div>"; $i++; } } } Thanks in advance!
  • 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.