PHP - Selling Api Access
I've got data in a mySql database which is updated daily. I would like to allow webmasters to place this data in a form of a widget on their websites provided they pay for access. If not payment comes through we should be able to block access.
Any suggestions how this project would be designed?
Similar TutorialsHere's my thought: A person buys data, they have a quota, I'm talking about cellular networks. In any area, a tower or provider is more prevalent / stronger than others. What if, a person could install an app that allowed them to broadcast / be as a hotspot while getting paid per kb "sold". Technically I am not breaking the law am I? I mean that person 'paid' for that data. What is the difference between selling it to someone for money on their behalf (and mine) as opposed to wasting it on useless activities like browsing social media sites... ?
It would be an app that has both parties, "searching" and "transmitting".
What is "illegal" about this?
Aside from obvious problems like security I'm currently learning PHP and I think I have a decent grasp of procedural programming so I'm trying to set it up a little bit and get a hang of OOP. I'm finding it a little tough going but I am making progress, the syntax and coding of it is fine but I don't quite get some theory and the best way to use it yet. It's only my third day in but I have a question relating to access modifiers. It's a simple one, but what is the point? That may sound a bit narky but I keep hearing and reading that it's good programming convention but it's never really explained why. What am I missing? I get how they work but I don't really get why to use them. I've even read that private should only be rarely used, if at all as it makes testing harder and it stops you from being able to extend your classes. I'm not against using them - I want to learn to program to the very best of my ability but I'm eager to learn what benefits it actually has. Is there a technical reason, for example? Hi I'm after a solution to a problem I have. I'm building a small site for charity which the the client wants to email(with a url link) to say 1000 selected companies but only wants them to be able to view the site and register interest and not anyone else or if they forward the mail to a non prefered client? Any help to point me in the right direction would be good thank-you. Hello, folks. I am having a little trouble with this script. I want it to be able to read a directory, not just a file, and list all files in the directory along with their id3 tags. I can't get it to read all the files, it reads only the first file in the directory. Here, I'm posting the basic (stripped down) script, without mods or add-ons. I would appreciate any help. Thanks. Code: [Select] <?php require('error.inc.php'); require('id3.class.php'); $nome_arq = 'music.mp3'; $myId3 = new ID3($nome_arq); if ($myId3->getInfo()){ echo('<HTML>'); echo('<a href= "'.$nome_arq.'">Click to play: </a><br>'); echo('<table border=1> <tr> <td><strong>Artist</strong></td> <td><strong>Title</strong></font></div></td> <td><strong>Track</strong></font></div></td> <td><strong>Album/Year</strong></font></div></td> <td><strong>Genre</strong></font></div></td> <td><strong>Comments</strong></font></div></td> </tr> <tr> <td>'. $myId3->getArtist() . ' </td> <td>'. $myId3->getTitle() . ' </td> <td>'. $myId3->getTrack() . ' </td> <td>'. $myId3->getAlbum() . '/'.$myId3->getYear().' </td> <td>'. $myId3->getGender() . ' </td> <td>'. $myId3->tags['COMM']. ' </td> </tr> </table>'); echo('</HTML>'); }else{ echo($errors[$myId3->last_error_num]); } ?> Hi, i am learning WordPress and have just started, but i have a problem....when i try to access my site i get this: Warning: Cannot modify header information - headers already sent by (output started at /home/smra9/public_html/wp-content/themes/evanescence/functions.php:6) in /home/smra9/public_html/wp-includes/pluggable.php on line 890 when i open pluggable.php and i go to the line 890 it says: header("Location: $location", true, $status); i will also copy a text from line 885 to 890 so maybe you will understand better: if ( $is_IIS ) { header("Refresh: 0;url=$location"); } else { if ( php_sapi_name() != 'cgi-fcgi' ) status_header($status); // This causes problems on IIS and some FastCGI setups header("Location: $location", true, $status); } Can anyone help me, i don't know what to do Hey Guys.
I have a class named CoreCartFunctions. In the class there is a protected property named $menu_item_id which is initialized as null.
A method named GetMenuItemId assigns the $menu_item_id its value. I have tested it out using the following, to see if a value got returned and it did
fb($menu_item_id->GetMenuItemId(), "This is the menu id");The problem is when I access the property from a different public method in the same class it dones't return anything. fb($menu_item_id->DisplayMenuItems());It only returns something when I hard code a value to it.... Not sure why this is happening. Here is my full code. Please not the example below may have some syntax errors since I just copied and paste pieces of my code, to show a quick and dirty example. class CoreCartFunctions { protected $menu_item_id = NULL; public static $items; //Equal to the a long session string protected function GetMenuItemId() { foreach (self::$items as $menu_item_id_session) { /*********************************** Get the id of the menu item item ************************************/ $this->menu_item_id = preg_match_all('/\-(.*?)\*/',$menu_item_id_session,$match_found)?$match_found[1][0]:""; // The following line shows example of above line // $menu_item_id = "12"; public function DisplayMenuItems(){ return $this->menu_item_id; // Doesn't return Item ID } } When I send values to the foreach they are not recorded in the array. $x = $getProductID; $_SESSION['pColors'] = array(); if(isset($_POST['pColors'])) { foreach($_POST['pColors'] as $colorKey => $RColors) { $_SESSION['pColors'][$colorKey] = $RColors; } } var_dump($_SESSION['pColors']); Send date with AJAX: $('.addToCart').click(function(){ $.ajax({ url:""+realLink+"cart.php", method:"POST", data:{action:action,pColors:pColors}, success:function(data){ //alert(data); } }); }); Hi, I want to control a variable (decide whether to track click if coming from a specific site oppose to hitting the final site (destination) directly. For example: www.portal.com - this will be a management site that will redirect viewers to the the final destination based on variable info - for exmample $a=123 or $a= 567 - which would come in as www.portal.com?a=123 or www.portal.com?a=567 Note: 123 would redirect to www.abc.com?a=123 and/or 567 would redirect to www.xyz.com?a=567 with said variable(s). ------ My question is this: What is the best method to authenticate (both on) www.abc.com and/or www.xyz.com that the referred viewer came from www.portal.com? I know about the super globals (HTTP_REFERER) but want to know if there are other (more) secure method to manage this interaction between external domains /websites? Any insight on this appreciated - thanks! Array ( [game] => Array ( [id] => 2011012593950636050 [name] => Array ( [us] => Castlevania II: Belmont's Revenge [uk] => Castlevania II: Belmont's Revenge ) echo print_r($this->game[0]['name']) but undefined offset error. I don't want to loop through the first array either. Thanks If a client connects to a ReactPHP TLS socket server, is it possible to obtain the symmetric key from within the PHP code? Hoping it will allow me to decrypt analysis traffic between two using Wireshark. Hi guys, I am making a site where users upload files (like images, pdfs, etc) to the server. My question is, how does Facebook handle file permissions, restricting access to files uploaded to their servers based on what a user sets? Because I need to implement a similar thing and have no idea how to do it in a clean way. I have had two thoughts on storing the files 1) in a DB or 2) in a folder out of the wwwroot, which would prevent access by anyone without knowing the path (or some such) but it is the more "real" permissions implementation I am stuck on. I obviously would like to achieve this with PHP and MySQL(i). Any help is much appreciated. Cheers in advance. I want to make it so public users cant access the index of/ page, how do I do that? Thanks Hi,
I am building a restfull service and i would like to out put a error like the following
{ "error": true, "message": "Validation failed", "code": 400, "errors": [ { "field": "first_name", "error": "The first name field is required." }, { "field": "first_name", "error": "The last name field is required." }, { "field": "first_name", "error": "The gender field is required." }, { "field": "first_name", "error": "The city id field is required." }, { "field": "first_name", "error": "The postcode field is required." }, { "field": "first_name", "error": "The email field is required." }, { "field": "first_name", "error": "The password field is required." } ] }but i cant seem to read the array key as what the vailidation failed on $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { $errors = array(); $messages = $validator->messages(); //print_r($messages); foreach ($messages->all() as $value) { $errors[] = array('field' => 'first_name', 'error' => $value ); } $response = Response::json(array( 'error' => true, 'message' => 'Validation failed', 'code' => 400, 'errors' => $errors ) ); //$validator->messages() return $response; } Only thing I really miss from PHP is "internal" access modifier. Before I was making libraries and extensions in C# (like game frameworks, Tiled implementations, GUI loaders). Now, when I am working on my own PHP framework, I really miss internal, I was using it a lot in C#. Is internal planned to be added in PHP 7 or is it already in PHP 5.6 or it will never be added?
In my project. I wanted an option that was going to give me more control over what my users can and could not do. I fount a ACL Sample and well the guy that made this must have been drunk. Any way I been working with it and putting it together so that it will work. The problem is that when I view the users current permissions it doesn't seem to display then right. Blow is the code i have in a switch that I use to manage each users permissions. The $_GET['uid'] gets the users id from the URL in the admin section. Code: (php) [Select] case "manage": //$userACL = new ACL($_GET['uid']); $userACL = new ACL($_GET['uid']); echo '<h2>Managing '.$userACL->getUsername($_GET['uid']).'</h2>'; echo '... Some form to edit user info ...'; echo '<h5>Roles for user: (<a href="users.php?action=roles&uid='.$_GET['uid'].'">Manage Roles</a>)</h5>'; echo '<ul>'; $roles = $userACL->getUserRoles($_GET['uid']); foreach ($roles as $k => $v) { echo "<li>" . $userACL->getRoleNameFromID($v) . "</li>"; } echo '</ul>'; echo '<h6>Permissions for user: (<a href="users.php?action=perms&uid='.$_GET['uid'].'">Manage Permissions</a>)</h6>'; echo '<ul>'; //$uparms = $userACL->getAllPerms($_GET['uid']); //$uPerms = $userACL->getUserPerms($_GET['uid']); //$aPerms = $userACL->getAllPerms('full'); $aPerms = $userACL->perms; //foreach ($perms as $k => $v) foreach($aPerms as $k => $v) { //echo 'fdfdsfsd :'. $v['value']; //if ($v['value'] == false) { continue; } if($v['value']) { // if (!$v['value']) { continue; } echo "<li>" . $v['Name'] . ' : Allowed </li>'; //if ($v['inheritted']) { echo " (inheritted)"; } } else { echo "<li>" . $v['Name'] . ' : Deny </li>'; } echo "</li>"; } echo '</ul>'; break; If any one needs any extra info. Please let me know. I am using WAMP server for my PHP Server and am trying to connect to an Access Database with the extension of accdb, but I keep getting the error "could not find driver". Here is the code I'm trying to run:
$dbName = $_SERVER["DOCUMENT_ROOT"]."/Ridley/RLCompRepair.accdb";
if (!file_exists($dbName)) {
die("Could not find database file.");
}
try {
$db = new PDO("odbc:Driver={MS Access Database (*.mdb, *.accdb)};Dbq=$dbName");
} catch (PDOException $e) {
echo "Error: ".$e->getMessage();
}
I have enabled the php_pdo_odbc extension, so I'm pretty sure this is not the problem. Could someone please let me know what is wrong?
Chris
Edited by chrscote, 15 November 2014 - 02:45 PM. I'm trying to access the agemni.com webservice using php which has been a very hard since it is wrriten in .net <?php $client = new SoapClient("http://agemni.com/AgemniWebservices/service1.asmx?WSDL", array('trace' => 1)); $options->strUsername = "karth"; $options->strPassword = "7pk6Xc8o"; $options->strCompanyName = "webloon"; $options->objecttype = 2; $options->keys = array("fname", "lname", "phone", "zip", "area id", "lead id", "contactdate"); $options->values = array("John", "Doe", "859-333-3333", "40332", "12345", "28222", "4/10/2010"); $validate = $client->ValidateEntity($options); echo '<pre>'; echo var_dump($validate); echo '</pre>'; echo '<br><br>'; echo htmlspecialchars($client->__getLastRequest()); ?> I was able to connect using the credentials but I get a error, Conversion from type 'XmlNode()' to type 'String' is not valid. This is the relevant part from the getType method. Code: [Select] [3]=> string(18) "string statusCodes" [4]=> string(154) "struct ValidateEntity { string strUsername; string strPassword; string strCompanyName; int objecttype; ArrayOfAnyType keys; ArrayOfAnyType values; }" [5]=> string(43) "struct ArrayOfAnyType { anyType anyType; } Anyone knows how to pass ArrayOfAnyType using php? Thank you. Hi ; Im getting the below error from Access database please help me to fix it. [root@db_cesar home]# php test.php table name : t_b_Door column name : f_DoorID t is not a table in this database Error at Line : syntax error near _ PHP Warning: odbc_exec(): SQL error: [unixODBC]Couldn't parse SQL , SQL state 08001 in SQLExecDirect in /home/test.php on line 15 This is my code <?php $conn=odbc_connect("logindb","",""); if (!$conn) { exit("Connection Failed: " . $conn); } $sql="SELECT f_ReaderID FROM t_b_Reader"; $rs=odbc_exec($conn,$sql); if (!$rs) { exit("Error in SQL"); } while (odbc_fetch_row($rs)) { $f_ReaderID=odbc_result($rs,$f_ReaderID); //$conname=odbc_result($rs,"ContactName"); echo "$f_ReaderID \n"; } odbc_close($conn); ?> Thanks Is it possible to allow a script running on another server to write/read a specific file on my server? I can set file permissions, but not having any luck with file paths due to php5 blocking http:// urls. I have just set up MAMP on my new MacBook Pro and I am having trouble getting my MySQL connection working. When I use the following code: Code: [Select] $mysqli = new mysqli('localhost', 'application', 'application', 'dorset'); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (".$mysqli-errno.") ".$mysqli->connect_error; } I get this error: Failed to connect to MySQL: () Access denied for user 'application'@'localhost' (using password: YES) However if I use the old mysql_connect() function, it doesnt throw back any errors?! Any ideas? |