Jump to content

Search the Community

Showing results for tags 'api'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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 (PhpStorm, VS Code, 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi all, I'm working on a project involving an orders set of APIs, and having trouble coming up with the best logic to handle this - with the smallest amount of overhead and client facing slowness. Here's the jist of what I'm looking at... There are 21 API methods to pull different types of orders, and each of them handle paging by requesting a number of records (10 - 500), and a page number. So I could say in my URI, "page-no=1&no-of-records=50", followed by "page-no=2&no-of-records=50", to get subsequent records. The API will return in each call the total records returned as well as the total records in their database. Now, I want to insert all of this into my database, and so that means something like 21 APIs * 3 SQL requests each = 63 sql queries (check it exists, if so update - else insert). This seems to me like way too much work for a client facing application. Any suggestions?
  2. I really don't understand the point of an API. I am totally lost on this one. I have never in my life used JSON and barely touched Javascript so I'm already quite behind the curve but this was my understanding of the "purpose" of an API; You have some data in a database that others might find useful so you write a script that allows people to go in and pull data from it. So why aren't these APIs just built using PHP? If I have a database table of first names, last names and email-addresses, and for some reason I want other people on the internet to be able to get at that, then why don't I just write a one-page script that list them all out? Then all the user has to do is "include" it in their code, right? That's probably really over-simplistic, and I am surely missing the point. There must be a point, but I cannot find a single source anywhere with an actual decent explanation of this. What am I missing? You never know, perhaps you're all about to tell me that most APIs are built using PHP and what I've described is pretty much it. But everything I research leads to a dead end because they all refer to one another; Example 1 - "Oh JSON is freaking awesome. I use it because it's awesome. It's awesome for work working with APIs". Example 2 - "Oh, APIs, yeah, you totally have to have APIs. All you have to do is use JSON. It's awesome". Not direct quotes, but close enough! Seriously, help me out. I have a lot of public data on my server and I am positive that someone can make good use of it. But how?
  3. Hey Guys & Girls, Okay, so here's my little issue. I'm running a WordPress site with a custom PHP script using JSON/CURL/API pulling info from an API. All is good in the world in this respect. However, the API listings that are returned are only returned in a 50 item block. The API doesn't allow for more than 50 items per call. So, what I'm looking for is a way to paginate my results so that if there are more than 50 items in the API call, it will allow the user to click to page 2, 3, 4 etc. Here's my code: <?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.myapilink.com.au/api/listings?token=f716909f5d644fe3702be5c7895aa34e&group_id=10046&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: f716909f5d644fe3702be5c7895aa34e', )); $json = json_decode(curl_exec($ch), true); // Functions relating to the Echo Code foreach($json['listings'] as $listing) { $short_personality=substr($listing['personality'],0,500); $peturl="http://mysiteurl.com.au/beta/pet-info/?petid=".$listing['id']; $medium_photo=$listing['photos'][0]['large_340']; $gallery_listing=$listing['photos'][5]['large_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["large_340"]; $photo_thumb_hidden=$photosthumb["small_80"]; } $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://mysiteurl.com.au/beta/wp-content/themes/Archive/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://mysiteurl.com.au/beta/pre-adoption-form-dogs/?dog_name=$name"; $hwt="list-$heart_worm_tested"; } elseif($listing['species'] == "Cat") { $adoption_enquiry_link="http://mysiteurl.com.au/beta/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="'.$medium_photo.'"> <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 } curl_close($ch); ?> Attached is some dummy data that represents the JSON data returned from the API. As you can see in the file, the last line is where the paging details comes in. Any help you guys could give would be appreciated. Cheers, Dave listings.txt
  4. I want a PHP code to find the userID of a Facebook Account using Access Token. My form is like this:
  5. I have 100 Active Facebook access tokens. For each account I have more than one access token. I want to keep only one token for each account and want to delete the others. And i don't want to do this manually so please post a PHP script which check all the tokens and keep only one active token for each account. These tokens are present in a folder named "tok3ns".
  6. I have a facebook app working at https://apps.facebook.com/inboxcupid/ When trying to log in from a mobile device, the GetUser method always return 0. It actually creates a redirect loop as the page is constantly redirected to login, return to the app page and then back to login. It's imperative to know that this code works just fine on a desktop but fails on mobile. Here is my code: require_once ('facebook.php'); $config = array( 'appId' => '*****', 'secret' => '*****' ); // Create the Facebook object $facebook = new Facebook($config); $login_params = array( 'canvas' => 1, 'scope' => 'basic_info, user_about_me, user_birthday, user_relationships, user_relationship_details, user_location, user_photos', 'fbconnect' => 1, ); $user = $facebook->getUser(); if($user) { try { $permissions = $facebook->api("/me/permissions"); if( !array_key_exists('basic_info', $permissions['data'][0]) || !array_key_exists('user_location', $permissions['data'][0]) || !array_key_exists('user_about_me', $permissions['data'][0]) || !array_key_exists('user_birthday', $permissions['data'][0]) || !array_key_exists('user_relationships', $permissions['data'][0]) || !array_key_exists('user_relationship_details', $permissions['data'][0]) || !array_key_exists('user_photos', $permissions['data'][0]) ) { $login_url = $facebook->getLoginUrl($login_params); echo "<script" . " type='text/javascript'" . ">top.location.href = '$login_url';</script>"; } } catch(FacebookApiException $e) { $login_url = $facebook->getLoginUrl($login_params); echo "<script" . " type='text/javascript'" . ">top.location.href = '$login_url';</script>"; error_log($e->getType()); error_log($e->getMessage()); } } else { $login_url = $facebook->getLoginUrl($login_params); echo "<script" . " type='text/javascript'" . ">top.location.href = '$login_url';</script>"; } If anyone can help me figure it out I'll be thankful.
  7. I have used Dropbox API in my website. I have completed Oauth and I'm successfully getting metadata. now i'm clueless.. MetaData: Metadata content for / Array ( [hash] => [thumb_exists] => [bytes] => 0 [path] => / [is_dir] => 1 => 0 bytes [root] => app_folder [contents] => Array ( [0] => Array ( [revision] => 20 [rev] => [thumb_exists] => 1 [bytes] => 6974 [modified] => Fri, 28 Feb 2014 11:02:10 +0000 [client_mtime] => Fri, 28 Feb 2014 11:02:10 +0000 [path] => /skhan.jpg [is_dir] => [icon] => page_white_picture [root] => dropbox [mime_type] => image/jpeg => 6.8 KB ) How can i use this metadata to show files to users? please help
  8. I've tried all day looking for the official documentation for the Arzoo api but didn't find one.. all i can see from the net is code examples(like the one below) from people and following that isn't really helpful <?php $location_URL = "http://59.162.33.102/ArzooWS/services/DOMFlightAvailability";$action_URL ="http://com.arzoo.flight.avail";$client = new SoapClient('http://59.162.33.102/ArzooWS/services/DOMFlightAvailability?wsdl', array('soap_version' => SOAP_1_1,'location' => $location_URL,'uri' => $action_URL,'style' => SOAP_RPC,'use' => SOAP_ENCODED,'trace' => 1,));$request = array('Request'=>array('Origin' => 'BOM','Destination' => 'DEL','DepartDate' => '2013-09-05','ReturnDate' => '2013-09-06','AdultPax' => '1','ChildPax' => '0','InfantPax' => '0','Currency' => 'INR','Clientid' => '777xxxx','Clientpassword' => '*5AF72AA053B7823D8EBBFE696080C9AD6B3DF69A','Clienttype' => 'ArzooFWS1.0','Preferredclass' => 'E','mode' => 'ONE','PreferredAirline' => 'AI,G8,IC,6E,9W,S2,IT,9H,I7,SG'));try{ $result = $client->__call('getAvailability',$request); $response= htmlentities($result);}catch(Exception $e){ echo "<h2>Exception Error!</h2>"; echo $e->getMessage();}var_dump($response);?> i want to use the Arzoo api to look up hotel and air ticket prices..any references on the official documentation of Arzoo api or any relevant material would be helpful
  9. Good Afternoon All, I have set out to create a script which will hopefully add an event to an existing google calendar (as a background process using details recorded during the completion of a form) the script to initalise on the submission of the form. However, I have been unable to achieve any results whilst working on this task, I have only witnessed blank screens. Perhaps I am doing something wrong? Can you help? The required steps: 1. user completes form including date from & date to. 2. user clicks submit 3. onclick(); starts php script 4. php script takes the dates as variables 5. php script uses the predefined google account username and password to authenticate 6. User returns to homepage (Google event added) This is my code so far: (removed ID's for privacy) <?php error_reporting(E_ALL); require_once 'google-api-php-client/src/Google_Client.php'; require_once 'google-api-php-client/src/contrib/Google_CalendarService.php'; session_start(); if ((isset($_SESSION)) && (!empty($_SESSION))) { echo "There are cookies<br>"; echo "<pre>"; print_r($_SESSION); echo "</pre>"; } // This is the file I am using ,,, i have cut out the ID's for privacy $client = new Google_Client(); $client->setApplicationName("Google Calendar PHP Starter Application"); $client->setClientId('MY CLI ID HERE'); $client->setClientSecret('MY CLI SECRECT KEY HERE'); $client->setRedirectUri('http://localhost/index.php'); $client->setDeveloperKey('MY API KEY HERE'); $cal = new Google_CalendarService($client); if (isset($_GET['logout'])) { echo "<br><br><font size=+2>Logging out</font>"; unset($_SESSION['token']); } if (isset($_GET['code'])) { echo "<br>I got a code from Google = ".$_GET['code']; // You won't see this if redirected later $client->authenticate($_GET['code']); $_SESSION['token'] = $client->getAccessToken(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); echo "<br>I got the token = ".$_SESSION['token']; // <-- not needed to get here unless location uncommented } if (isset($_SESSION['token'])) { echo "<br>Getting access"; $client->setAccessToken($_SESSION['token']); } if ($client->getAccessToken()){ echo "<hr><font size=+1>I have access to your calendar</font>"; $event = new Google_Event(); $event->setSummary('Halloween'); $event->setLocation('The Neighbourhood'); $start = new Google_EventDateTime(); $start->setDateTime('2013-9-29T10:00:00.000-05:00'); $event->setStart($start); $end = new Google_EventDateTime(); $end->setDateTime('2013-9-29T10:25:00.000-05:00'); $event->setEnd($end); $createdEvent = $cal->events->insert('###', $event); echo "<br><font size=+1>Event created</font>"; echo "<hr><br><font size=+1>Already connected</font> (No need to login)"; } else { $authUrl = $client->createAuthUrl(); print "<hr><br><font size=+2><a href='$authUrl'>Connect Me!</a></font>"; } $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; echo "<br><br><font size=+2><a href=$url?logout>Logout</a></font>"; ?> <html></html> Here's a video demonstration I created: http://www.youtube.com/watch?v=m3N4YbqiYR8 Many Thanks for reading and future contributions towards helping me. Josh
  10. I'm trying to use an API to submit a form and I'm not sure what I'm supposed to do with the ProcessName. This is the error I'm getting: 90028910falseInvalid Process Name0 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.securecrmsite.com/"> <SOAP-ENV:Body> <ns1:Process> <ns1:Credentials> <ns1:CompanyKey>xxxx</ns1:CompanyKey> <ns1:APIKey>xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns1:APIKey> </ns1:Credentials> </ns1:Process> <param1> <item> <key>ProcessName</key> <value>CompanyInsert</value> </item> <item> <key>FirstName</key> <value>From</value> </item> <item> <key>LastName</key> <value>API</value> </item> </param1> </SOAP-ENV:Body> </SOAP-ENV:Envelope> And this is the code I have: $compKey = 'xxxx'; $apiKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; $soapURL = "https://www.securecrmsite.com/Modules/System/API.asmx?wsdl"; $soapCredentials = array('Credentials'=>array('CompanyKey' => $compKey, 'APIKey' => $apiKey)); $soapFunctionParameters = array('ProcessName' => "CompanyInsert", 'FirstName' => "From", 'LastName' => "API"); $client = new SoapClient($soapURL, array('trace' => true)); $client->Process($soapCredentials, $soapFunctionParameters); echo $client->__getLastResponse(); If anyone has any ideas, they'd be greatly appreciated! I don't have much experience working with APIs. Thanks.
  11. I am having trouble actually translating this curl API that is not given in PHP form into one that can be used with PHP. Below is what the documentation says. curl -s "https://api.example.com/v1/users/?per_page=3" \ -X GET \ -u app-id:api-key I have tried several examples such as: $ch = curl_init('https://api.example.com/v1/users/?per_page=3'); curl_setopt($ch,CURLOPT_HTTPHEADER,array('app-id:5435435435', 'api-key:fdskajf234jfdsakfhdjkfaas')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); And: $ch = curl_init('https://api.example.com/v1/users/?per_page=3'); curl_setopt($ch,CURLOPT_HTTPHEADER,array('5435435435:fdskajf234jfdsakfhdjkfaas')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); Now what I believe is throwing me off is the "-u". When I navigate to the api URL in my browser, an authentication box comes up asking for my username and password. If I put in the app-id as the username and the api-key as the password it works. But again that is in the browser. How do I get past that with PHP? Any help is greatly appreciated.
  12. Unfortunately, I have been asked to stop importing CSV data into phpMyAdmin and instead call on a file that sits on another IP address. My head hurts thinking about it. I have the IP address and I think the name of the file. But I really need to be pointed to API 101 or something. I'm at a complete loss.. Anybody able to give advice? <?php $username = "username"; $password = "password"; $hostname = "hostname"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("DB",$dbhandle) or die("Could not select DB"); $metode = mysql_real_escape_string($_POST['metode']); $search = mysql_real_escape_string($_POST['search']); $query = mysql_query("SELECT strLodgeName, intLodgeNumber, intDistrictID, strLodgeLocationCity, strLodgeMailingPostCode FROM tblLodges WHERE TRIM(LEADING '0' FROM $metode) = '$search' GROUP BY strLodgeName LIMIT 50"); while ($row = @mysql_fetch_array($query)) { echo "<tr bgcolor=\"#dddddd\"><td><center>"; echo $row["intLodgeNumber"]; echo "</center></td><td><center>"; echo ltrim($row["strLodgeName"], '0'); echo "</center></td><td><center><span class=\"style2\">"; echo "<input name=\"submit\" type=\"button\" value=\"Lodge Details\" onclick=\"javascript:window.location='http://www.customer.com/lodgelocator/3view.php?id="; echo $row["intLodgeNumber"]; echo "'\" /></center></td>"; echo "</center></td><td><center>"; echo ltrim($row["strLodgeLocationCity"], '0'); echo $row["strLodgeLocationCity"]; echo "</center></td><td><center>"; echo ltrim($row["intDistrictID"], '0'); }?>
  13. Hi there, I am having a small problem getting php to work with google maps APIs. Basically, I have an API url where I pull down lat/long coordinates from for 10 houses and then I want these to map out on the google maps. So, I am not sure how to link the 2 together.. Here is what I have so far: <?php // Loading Domus API $url_search = 'http://url/site/go/api/search'; $xml_search = @simplexml_load_file($url_search) or die ("no file loaded") ; //Displaying latitude and longutude $xml_search = json_decode($xml_search); foreach($xml_search->property as $house) { echo $lat = $house->address->latitude , $long = $house->address->longitude; }; ?> and JavaScript bit: var locations = [ ]; var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: new google.maps.LatLng(-33.92, 151.25), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } Many thanks
  14. I'm trying to accessing value from json api instagram. I've successed to access simple api that returns like this: { "pagination": { }, "meta": { "code": 200 }, "data": [ { "attribution": null, "tags": [ ], "type": "image", "location": null, "comments": { "count": 0, "data": [ ] }, "filter": "Normal", "created_time": "1339298544", "link": "http:\/\/instagram.com\/p\/LrZfG6sU_l\/", "likes": { "count": 0, "data": [ ] }, "images": { "low_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_6.jpg", "width": 306, "height": 306 }, "thumbnail": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_5.jpg", "width": 150, "height": 150 }, "standard_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_7.jpg", "width": 612, "height": 612 } }, "users_in_photo": [ ], "caption": null, "user_has_liked": false, "id": "210373896496566245_180213154", "user": { "username": "realwahyuputra", "website": "", "profile_picture": "http:\/\/images.ak.instagram.com\/profiles\/profile_180213154_75sq_1359089013.jpg", "full_name": "realwahyuputra", "bio": "", "id": "180213154" } } ] } Since im trying to tricky the API to get all user media in one account, i combine API and next pagination api in one file named cache.json. Now it looks like this: { "pagination": { }, "meta": { "code": 200 }, "data": [ { "attribution": null, "tags": [ ], "type": "image", "location": null, "comments": { "count": 0, "data": [ ] }, "filter": "Normal", "created_time": "1339298544", "link": "http:\/\/instagram.com\/p\/LrZfG6sU_l\/", "likes": { "count": 0, "data": [ ] }, "images": { "low_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_6.jpg", "width": 306, "height": 306 }, "thumbnail": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_5.jpg", "width": 150, "height": 150 }, "standard_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_7.jpg", "width": 612, "height": 612 } }, "users_in_photo": [ ], "caption": null, "user_has_liked": false, "id": "210373896496566245_180213154", "user": { "username": "realwahyuputra", "website": "", "profile_picture": "http:\/\/images.ak.instagram.com\/profiles\/profile_180213154_75sq_1359089013.jpg", "full_name": "realwahyuputra", "bio": "", "id": "180213154" } } ] } { "pagination": { }, "meta": { "code": 200 }, "data": [ { "attribution": null, "tags": [ ], "type": "image", "location": null, "comments": { "count": 0, "data": [ ] }, "filter": "Normal", "created_time": "1339298544", "link": "http:\/\/instagram.com\/p\/LrZfG6sU_l\/", "likes": { "count": 0, "data": [ ] }, "images": { "low_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_6.jpg", "width": 306, "height": 306 }, "thumbnail": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_5.jpg", "width": 150, "height": 150 }, "standard_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_7.jpg", "width": 612, "height": 612 } }, "users_in_photo": [ ], "caption": null, "user_has_liked": false, "id": "210373896496566245_180213154", "user": { "username": "realwahyuputra", "website": "", "profile_picture": "http:\/\/images.ak.instagram.com\/profiles\/profile_180213154_75sq_1359089013.jpg", "full_name": "realwahyuputra", "bio": "", "id": "180213154" } } ] } { "pagination": { }, "meta": { "code": 200 }, "data": [ { "attribution": null, "tags": [ ], "type": "image", "location": null, "comments": { "count": 0, "data": [ ] }, "filter": "Normal", "created_time": "1339298544", "link": "http:\/\/instagram.com\/p\/LrZfG6sU_l\/", "likes": { "count": 0, "data": [ ] }, "images": { "low_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_6.jpg", "width": 306, "height": 306 }, "thumbnail": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_5.jpg", "width": 150, "height": 150 }, "standard_resolution": { "url": "http:\/\/distilleryimage5.s3.amazonaws.com\/7f69259cb2ab11e1989612313815112c_7.jpg", "width": 612, "height": 612 } }, "users_in_photo": [ ], "caption": null, "user_has_liked": false, "id": "210373896496566245_180213154", "user": { "username": "realwahyuputra", "website": "", "profile_picture": "http:\/\/images.ak.instagram.com\/profiles\/profile_180213154_75sq_1359089013.jpg", "full_name": "realwahyuputra", "bio": "", "id": "180213154" } } ] } How to accessing that value in PHP? There are three data value either when the simple api just one data value. Im using this code to accessing that value but doesn't worked: $cache = './cache.json'; $response = json_decode(file_get_contents($cache),true); //Decode as an json array if(is_array($response['data'])){ foreach ($response['data'] as $data) { if ($data['comments']['data'] != null) { foreach($data['comments']['data'] as $comment){ ...
  15. hello, i am new to php programming.. i need to execute this url in my send sms.php file.. i tried curl method but failed.. API URL is , sample" http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=hidden&password=hidden&sendername=iZycon&mobileno=8289947807 i just need to execute this url in my page... while replying plz include the php code..
  16. I am trying to create a search query for either the YearBuilt (yachts.theskywatergroup.com/yatco_data_feeds/datafeed_customer/query2.php) or LocationState a Vessel is located in (yachts.theskywatergroup.com/yatco_data_feeds/datafeed_customer/query3.php.) See attached files. I can only get the full return of the URI. I am not fluent in PHP coding as I am more involved in web design, graphics, emarketing, etc., but want to learn this for one of my friend's who is a Yacht broker. Part of the example response data from the "Search" URI is below. A few questions as this is new to me - 1 - What are the numbers and "String content" in JSON? 2 - Can $_Get('City') be a request from a form? 3 - Is it my code in the attached files or is there something else I need from the providing Dataservice? { "PageCount":"2147483647, "RecordCount":2147483647, "Vessels":[( "AskingPriceFormatted":"String content", "City":"String content", "VesselID":2147483647, "YearBuilt":2147483647 )] } query3.php query_results3.php query_results2.php query2.php
  17. Hello, I was studying through the CANVAS LMS and looked at a few demonstrations that were at dev cons. The problem is the canvas LMS is built with Ruby I believe so all the demos to connect to the API were using Ruby. Unfortunately the app that I'm working this into is using PHP, so once I develop the module for this part of the app I nned to figure out what the best way to do this is. Will I be able to use Ruby to do in this app as well? It's using something called Kurogo and most of the other modules that call data use PHP. So I'd prefer to use PHP, but I see no good documentation for getting it (CANVAS LMS API) running with PHP. I'm just trying to study up on this for when I'll be building this new part of the app in the summer most likely (or fall) and want to figure out the best course of action or where I can find decent documentation ofr this. Thanks in advance!
  18. Below is PHP using CURL with JSON to POST data to the MemberClicks API. I keep getting a 413 error when trying to process the page. I've tried a few things, but none seem to work. So far I don't get and syntax errors just on the 413. <?php if (!empty($_POST['userid']) && !empty($_POST['username']) && $_POST['data']=="Update") { $dateATOM = date(DATE_ATOM); $groupid = "12345"; $org = "ABCco"; $userid = $_POST['userid']; $username = $_POST['username']; $contactname = $_POST['contactname']; $email = $_POST['email']; $firstname = $_POST['firstname']; $middlename = $_POST['middlename']; $lastname = $_POST['lastname']; $businessaddress1 = $_POST['businessaddress1']; $businessaddress2 = $_POST['businessaddress2']; $businesscity = $_POST['businesscity']; $businessstate = $_POST['businessstate']; $businessinternationalstate = $_POST['businessinternationalstate']; $businesscountry = $_POST['businesscountry']; $businesszip = $_POST['businesszip']; $companyname = $_POST['companyname']; $title = $_POST['title']; $businessphone = $_POST['businessphone']; $mobilephone = $_POST['mobilephone']; $extension = $_POST['extension']; $fax = $_POST['fax']; $url = $_POST['url']; // Establish $url = 'https://####.memberclicks.net/services/auth'; $data = 'apiKey=123&username=user&password=pass'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $httpHeaders[] = "Accept: application/json"; curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders); curl_close($ch); $token = $jsonResult->token; // end --> $raw_json ='{"userId": "'.$userid.'","groupId":"'.$groupid.'","orgId":"'.$org.'","contactName": "'.$contactname.'","userName": "'.$username.'","attribute":[{"userId": "'.$userid.'","attId":"528954","attTypeId":"10", "attData": "'.$username.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"528955","attTypeId":"16", "attData": "'.$contactname.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"528950","attTypeId":"1", "attData": "'.$email.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529209","attTypeId":"2", "attData": "'.$firstname.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529210","attTypeId":"7", "attData": "'.$middlename.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529211","attTypeId":"3", "attData": "'.$lastname.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529213","attTypeId":"28", "attData": "'.$businessaddress1.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529214","attTypeId":"29", "attData": "'.$businessaddress2.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529215","attTypeId":"30", "attData": "'.$businesscity.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529216","attTypeId":"31", "attData": "'.$businessstate.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529240","attTypeId":"7", "attDate": "'.$businessinternationalstate.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529217","attTypeId":"33", "attData": "'.$businesscountry.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529218","attTypeId":"32", "attData": "'.$businesszip.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529219","attTypeId":"7", "attData": "'.$companyname.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529220","attTypeId":"7", "attData": "'.$title.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529221","attTypeId":"5", "attData": "'.$businessphone.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529244", "attData": "'.$mobilephone.'","attTypeId":"5","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529222","attName":"Extension", "attData": "'.$extension.'","lastModify": "'.$dateATOM.'"},{"userId": "'.$userid.'","attId":"529223","attTypeId":"14", "attData": "'.$fax.'","lastModify": "'.$dateATOM.'"}, {"userId": "'.$userid.'","attId":"529228","attTypeId":"15", "attData": "'.$url.'","lastModify": "'.$dateATOM.'"}]}'; $json = json_decode($raw_json); $url2 = 'https://####.memberclicks.net/services/user/'.$userid.'/?includeAtts=true'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url2); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_POST, true); $httpHeaders[] = "Accept: application/json"; $httpHeaders[] = "Authorization: ".$token; curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders ); curl_setopt($ch, CURLOPT_FAILONERROR, true); $results = curl_exec($ch); if (curl_errno($ch)) { echo "<h2>Yes</h2>"; print "<strong>".curl_getinfo( $ch, CURLINFO_HTTP_CODE )."</strong><br><br>"; print "<strong>".curl_error($ch)."</strong><br><br>"; echo "<hr><p>".var_dump($json)."</p>"; } else { echo "<h2>No</h2>"; print curl_getinfo( $ch, CURLINFO_HTTP_CODE ); curl_close($ch); echo "<hr><p>".var_dump($json)."</p>"; //print curl_error($ch); //echo "<p>".$raw_json."</p>"; //header("location: getAll.php?error=Something Happened!"); } return $results; } else { header("location: getAll.php?error=Nothing Happened!"); } ?>
  19. Basically what I can see is that I am failing to create the apiContext object. Can anyone see where the error is? Please tell me how I can improve the question. Here is the error: Fatal error: Uncaught exception 'PayPal\Exception\PPConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:104 Stack trace: #0 /vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(44): PayPal\Core\PPHttpConnection->execute('{"intent":"sale...') #1 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(246): PayPal\Transport\PPRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...') #2 /pymt.php(38): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #3 {main} thrown in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 104 This is the PHP sample I'm using. I am trying to run it off my server. If a customer clicks the pay with paypal button, it runs the following sample script: <?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; session_start(); $payer = new Payer(); $payer->setPayment_method('paypal'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('1.00'); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment description.'); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturn_url('baseUrl/sale.php'); $redirectUrls->setCancel_url('baseUrl/saleFail.php'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setRedirect_urls($redirectUrls); $payment->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (\PPConnectionException $ex) { echo 'Exception: ' . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirectUrl = $link->getHref(); } } $_SESSION['paymentId'] = $payment->getId(); if(isset($redirectUrl)) { header('Location: $redirectUrl'); exit; } ?> Here's the redacted bootstrap.php: <?php /* * Sample bootstrap file. */ // Include the composer autoloader if(!file_exists(__DIR__ .'/vendor/autoload.php')) { echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n"; exit(1); } require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/common.php'; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; $apiContext = getApiContext(); /** Helper method for getting an APIContext for all calls * * @return PayPal\Rest\ApiContext */ function getApiContext() { // ### Api context // Use an ApiContext object to authenticate // API calls. The clientId and clientSecret for the // OAuthTokenCredential class can be retrieved from // developer.paypal.com $apiContext = new ApiContext( new OAuthTokenCredential( 'MY CLIENT ID', 'MY SECRET' ) ); // Register the sdk_config.ini file in current directory // as the configuration source. if(!defined("PP_CONFIG_PATH")) { define("PP_CONFIG_PATH", __DIR__); } return $apiContext; } ?> Can anyone help? Let me know if you need more info. Thanks up front.
  20. Hey All, Does anyone have any good articles or books on how to create a public API with PHP. I understand how API's work, although it wouldn't hurt to read up on them, but I am really just looking to understand how one can be built with PHP. Thanks in advance,
  21. Hi All, It is nice to be back on the forum again! I was wondering if anyone knew about any cost effective API's for geocoding. For anyone who does not know what geocoding is, it is when a user submits an address and you then convert or geocode that address into latitude and longitude. A project that I am starting up requires an API that uses latitude and longitude and the parameters in the method. I know that Google, Map Quest and Yahoo all have API's for geocoding, but I am looking for something a little more cost effective that can take a little more traffic before hitting the limit. Thanks in advance!
  22. Hi PHPFreaks =), I'm in need of some guidance. Is it possible and safe to open a SOAP Connection every 10-15 minutes? Thanks, Hal
  23. Hi, I'm having trouble accessing the Toggl Reporting API. I wondered whether anyone has experience accessing this or similar REST based services? I get the error message 'api token not valid', although I have tried several api tokens that are definitely valid, and also tried encoding the token with base 64 (as suggested to access via http basic auth). I wanted to check whether there are any obvious errors in the code? I'm using cURL as suggested in the documentation but don't have much experience with this. header('Content-type: application/json'); $token = "[myapitoken]";//my api token function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_USERPWD, $token.':api_token'); $data = curl_exec($ch); curl_close($ch); return $data; } $returned_content = get_data("https://toggl.com/reports/api/v2/weekly?&workspace_id=282507&since=2013-05-19&until=2013-08-20&user_agent=[user agent]");//user agent here var_dump($returned_content);
  24. Dear pals, I am newbie in RESTful services . I need to call a GET Verb in Server . I know 2 methods 1. Ajax Call we can write it as $.ajax({ url: url, dataType: "html", type: 'GET', data: "id="+id+"&type="+type, success: function(data){ //$("#content").html(data); alert(data); $('table #sample-boxed-2-pagination th a').each(function(){ //this.href = this.href.replace(sub_url, main_url); var value = this.href.split('?'); //alert(value[0]); if(value[0]!=sub_url) { this.href = this.href.replace(value[0], sub_url); } }); } }); }); But I know it's not working in Cross domain scenario . Please advise a method to work same in all domains . 2. Using file_get_contents() function like $response = file_get_contents('https://kkl.com/graph/call?parm1=9'); I know I can call POST verb using cURL as $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://localhost/simple_rest_master/test"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); $data = array( 'username' => 'foo', 'password' => 'bar' ); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $contents = curl_exec($ch); curl_close($ch); echo $contents; // manipulate response Do you can advise the syntax of GET call using cURL ? Waiting your fast reply Thanks, Anes
  25. Dear Friends, I am using Simple-REST Library for my REST Web service purpose . I need to integrate "OAuth2" with my REST API skeleton. I attached the REST - API Client & Server for your reference . Please check it and help me with a good solution for implementation. Thanks, Anes simple_rest_client.zip simple_rest_master.zip
×
×
  • 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.