php,facebook,streamRelated issues-Collection of common programming errors
Jamal
php oop
I could use some review on this Auth class, as I’m sure it could use many improvements!I wrote this fairly quickly, so please forgive any overseen bugs.Example usage:// Login a user if (Auth::attempt($_POST[‘username’], $_POST[‘password’])) {echo ‘You have successfully logged in.’; }// Check if the user is a guest if (Auth::guest()) {echo ‘Please log in to see this page.’; }// Logout a user Auth::logout();Source code:<?phpclass Auth {/*** Whether or not the user is currently logged in** @var
Mawia HL
php mysql
Here is my code: $sql = <<<END Select Sum(p)/Sum(w)*100 as present FROM attendance group by month END; $query = mysql_query($sql) or die($sql . ‘ – ‘ . mysql_error()); $names = array(); while ($row = mysql_fetch_array($query)) {$names[] = $row[0]; }
John E
mac terminal php
So I am trying to upgrade the native php installation on my mac and i keep getting these errors:ld: library not found for -ljpeg clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libs/libphp5.bundle] Error 1Anybody know what the problem is?
flem
php javascript jquery
I have a couple form elements that when clicked update the database and disappear.At first, I have a button that reads Check In. Upon clicking it, the database is updated and a dropdown is presented in place of the button. In the dropdown, there are locations for the user to choose, that have values of their corresponding location-number, which upon clicking update the database. The last option is labeled Check Out, and upon clicking it, the database is supposed to be updated one last time, and
Fabien
php scope callback
class myClass {$myVariable = ‘myCallback’;function myFunction() {$body = false;$callback = $this->myVariable;function test($handle, $line) {global $body, $callback;if ($body) {call_user_func($callback, $line);}if ($line === “\r\n”) {$body = true;}return strlen($line);}…curl_setopt($ch, CURLOPT_WRITEFUNCTION, ‘test’);…} }function myCallback($data) {print $data; }$myCls = new myClass(); $myCls->myFunction();Warning: call_user_func() [function.call-user-func]: First argument is expected t
RaphaelDDL
php jquery ajax json-encode parse-error
I’m using PHP’s json_encode() to return some data, retrieved by jQuery’s ajax():Simplified JS:$.ajax({dataType: ‘json’,contentType: ‘application/json’,cache: false,type: ‘POST’,url: ‘./api/_imgdown.php’,error: function(jqXHR, textStatus, errorThrow) {console.log(jqXHR, textStatus, errorThrow);},success: function(data, textStatus, jqXHR) {console.log(data, textStatus, jqXHR);} });The PHP is:header(‘Content-Type: application/json; charset=UTF-8’); //default apiResponse $apiResponse = [“status” =&g
RSM
php if-statement
I have an input text area which when filled out and sent, puts whatever was typed in into the variable$inputThis is then put through an if statement to check whether or not its the letter a. If it is then echo – you wrote the letter a, else – you did not write the letter a. <?php $input = $_POST[“textarea”];echo $input;echo “<br />”;if($input = “a”){echo “You wrote a”;}else{echo “You did not write a”;}?>It does work, but in the wrong way. Every letter I type in comes as ‘You wrote
Thew
php api imgur
i have a question about the imgur api. I want to create a gallery for my website using the imgur api, but how can i create a file uploader that uploads to the imgur servers?Here is what i created:<?php include ‘xmlparser.php’; // From http://www.criticaldevelopment.net/xml/doc.php if($_SERVER[‘REQUEST_METHOD’] == “POST”){$data = file_get_contents($_FILES[“file”][‘tmp_name’]);// $data is file data$pvars = array(‘image’ => base64_encode($data), ‘key’ => HERE_MY_API_KEY);$timeout = 30;$
PeeHaa
php
For example is there a difference between the two? Is one preferred to the other?Class Node{ public $parent = null;public $right = null;public $left = null; function __construct($data){$this->data = $data; } }Class Node{ function __construct($data){$this->data = $data; $this->parent = null; $this->left = null; $this->right = null; } }
T9b
php mysql validation escaping sanitization
I’m just discovering PHPs sanitize and Validate filters, and I had been using MySQL’s mysql_escape_string to stop SQL Injection.Now I discover that PHP can also help and I guess logically these procedures are not exclusive in their function: ie you can sanitize and validate in PHP and still arrive at a situation where escaping is necessary.Am I right or am I overlooking something?
Peter Mortensen
android facebook
When I try to implement Facebook Connect in my Android application, I get the following error.Login failed:invalid_key:Android key mismatch. Your key”7dje38/jMXoU9Lezug4nzmZfFUg” does not match the allowed keysspecified in your application settings. Check your applicationsettings at http://www.facebook.com/developersHow do I fix it?
idrysdale
ruby-on-rails facebook opengraph koala
I’m building a small side project to test integrating Facebook’s Open Graph into a Rails application I’m building and am running into an odd issue. I can link a user (within the application) to my Facebook account, and successfully post an open graph update, however if I disconnect the app to my Facebook account, and link it to a test user generated within Facebook I receive the following error:u.facebook.put_connections(“me”, “goodgym:accept”, mission: “http://4ztq.localtunnel.com/missions/1”)
bkaid
ios facebook upload photo
I’d be grateful for any suggestions as to how to deal with a problem I’m having posting an image to Facebook.The following code works just as I would expect:NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@”http://myserver/img.png”, @”picture”,@”My Testing”, @”name”,@”Enter some text…”, @”message”,nil];[appDelegate.facebook dialog:@”feed” andParams:params andDelegate:self];However, I really want to use an image that I capture from my camera. I’ve set up the cod
Pratik
facebook facebook-opengraph opengraph
I am trying to post using facebook open graph for test user account. But I am getting the error “An unexpected error has occurred. Please retry your request later.”I read this “Just a head’s up, not sure if it’s a change, however unsubmitted Open Graph action types (i.e. review) can only be tested with an app Administrator or Developers account. Test accounts won’t work” on http://railscasts.com/episodes/363-facebook-open-graph?view=comments#comment_161576Could someone please let me know if I ca
p.s.w.g
java android eclipse facebook
I am trying to Login on FB with latest FB Sdk.Here is my codeSession currentSession = Session.getActiveSession(); if (currentSession == null || currentSession.getState().isClosed()) {Session session = new Session.Builder(v.getContext()).setApplicationId(getResources().getString(R.string.app_Id)).build();Session.setActiveSession(session);currentSession = session; } if (!currentSession.isOpened()) {Session.OpenRequest openRequest = null;openRequest = new Session.OpenRequest(FBLogin.this);if (openR
James Grigley
facebook facebook-graph-api facebook-test-users
I am in the process of having my watch action approved by Facebook but when I publish the action with a Test User it fails. This is a live environment, Sandbox-mode off.Error message: OAuth “Facebook Platform” “unknown_error” “An unexpected error has occurred. Please retry your request later.”I get similar results when I try to publish with the Graph API Explorer.However, it publishes fine for my admin user and all other “real” app users who are developers of the app. In any test I’ve done I can
Shlomi Dahan
facebook api facebook-fql
I want to publish All My Friends through appsWhen I put this code it brings me an errorParse error: syntax error, unexpected T_STRING, expecting ‘)’ in test111.php on line 19Can anyone help me? Thank yourequire “../settings.php”;require ‘../src/facebook.php’;require “../fbaccess.php”;require “web_config.php”;//user data from database$sql = mysql_query(“SELECT user_id,user_access_token,user_access_token_expire FROM data_table”);while ($data = mysql_fetch_array($sql)){$user_id = $data[‘user_id’];$
Neels
ios iphone facebook facebook-graph-api
Working on iPhone application for facebook integration, i have already taken some of the permissions from the user as follow :data = ({“basic_info” = 1;email = 1;”friends_birthday” = 1;”friends_photos” = 1;installed = 1;”public_profile” = 1;”user_birthday” = 1;”user_friends” = 1;”user_location” = 1;”user_photos” = 1;});Now I need one more permission from the user to post on his/her wall and that is publish_actionsI am using following code for gaining the user permission :NSArray *permissions
wqd
facebook sdk initialization facebook-javascript-sdk
Facebook SDK window.fbAsyncInit not firing on localhost? worked fine last week.<div id=”fb-root”></div> <script> window.fbAsyncInit = function() {console.log(“hey”);// init the FB JS SDKFB.init({appId : ‘***************’, // App ID from the App DashboardchannelUrl : ‘//localhost/channel.html’, // Channel File status : true, // check the login status upon init?cookie : true, // set sessions xfbml : true // parse XFBML tags on this page?}); }// Load the SDK’s s
YYZ
java facebook facebook-graph-api
I’m currently using Facebook4j to post links to facebook. The code I’m using to post : final Facebook facebook = new FacebookFactory().getInstance();facebook.setOAuthAppId(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET); final facebook4j.auth.AccessToken a = new facebook4j.auth.AccessToken(clipMeta.mFacebookKey); facebook.setOAuthAccessToken(a); final PostUpdate post = new PostUpdate(clipMeta.mFacebookText).caption(clipMeta.mFacebookText).picture(new URL(imageUrl)).link(new URL(url));final String postId =
Tshepang
c# stream filestream dispose
Say I want to define a TempFileStream class that creates a temporary file using Path.GetTempFileName() method. A temporary file must be deleted when TempFileStream’s object is no longer needed, e.g. closed or disposed:class TempFileStream: FileStream {string m_TempFileName = Path.GetTempFileName();public TempFileStream(FileMode fileMode): base(m_TempFileName,fileMode) {}/// …public ovverride Dispose(bool disposing){/// ???}}How should I implement this simply and safely?
Saint
java stream html-parsing
I write an application, that parse data from boards on the airport sites – Sheremetyevo (http://svo.aero/timetable/today/) and Domodedovo (http://www.domodedovo.ru/ru/main/airindicator/flightnew/). I create an object URL with the link of the site. Next, I call the method openStream. After that this stream is used with the parser HTMLEditorKit. With Domodedovo it works pretty good, but with the Sheremetyevo airport program behaves strangely. First, a certain number of launches of the application
Ziyao Wei
java string stream io
I find out to my puzzlement that the following snippet:void print() {System.out.print(“!”);System.out.print(“!\0”);System.out.flush(); // This line does not affect the outcomeSystem.out.println(“!”);System.out.println(“!”); }Will only print out:!! !I searched the Open JDK’s source code for the implementation, but no avail.The only clue have the clue that it seems BufferedOutputStream, and it seem to also have the similar “terminate on \u0000” behavior.Also I cannot find any documentation about t
Josh
c# stream icalendar
What’s the easiest way to filter a stream/reader line-by-line in c# (somewhat like putting sed in the middle of a pipeline). I want to feed an iCalendar file to DDay.iCal but DDay.iCal dies on “VERSION:5.1.1” because it wants a number or number SEMICOLON number (where number is digits (DOT digits)? so the last “.” is unexpected). What I want to do is filter the VERSION: line to something harmless like “VERSION:5.1” so the parser doesn’t die.Update: OK, here’s a sample: BEGIN:VCALENDAR PRODID:-//
Sss
c++ winapi stream dynamic-memory-allocation
I have created preview handler for a file and when i click on that file i get the preview of that file in preview pane and what the scene behind is i read the file by creating a stream and and that stream i store in a buffer and then i play with the buffer contents in order to create the preview on preview pane.Now my question is that i want to allocate the size of that file(of which i have create dpreview handler) dynamically (using visual c++) so that i would not need to allocate the memory
Bart Platak
java sockets stream
I’m developing Server-Client application and I have a problem with waiting for input data on input stream.I have thread dedicated to reading input data. Currently it uses while loop to hold until data is available. (N.B. protocol is as follow: send size of packet, say N, as int then send N bytes).public void run(){//some initializationInputStream inStream = sock.getInputStream();byte[] packetData;//some more stuffwhile(!interrupted){while(inStream.available()==0);packetData = new byte[inStream.r
Andy Prowl
c++ c++11 stream getline rvalue-reference
I ran into an unexpected compilation error when trying to use getline() with a temporary stream object:#include <iostream> #include <string> #include <sstream>using namespace std;int main() {string input = “hello\nworld\nof\ndelimiters”;string line;if (getline(stringstream(input), line)) // ERROR!{cout << line << endl;} }It looks like no overload of getline() exists that accepts an rvalue reference to a stream object. If I change main() to use an lvalue, it compiles
alessandro.francesconi
c# stream windows-phone isolatedstorage
My Windows Phone application saves an object composed by some textual/numerical information (something like image capture date and so on) and a couple of JPEG image. For example and simplicity, a single file may be composed by the following data order:from byte 0 to 3 —–> INT NUMBER from byte 4 to 11 —-> TWO INTs DESCRIBING THE SIZE OF THE NEXT IMAGE from byte 12 to X —-> FIRST JPEG IMAGE from byte X+1 to X+7 -> TWO INTs DESCRIBING THE SIZE OF THE NEXT IMAGE from byte X+8 to Y
Mahe
c# asp.net image stream system.argumentexception
Hi I am getting the “Parameter is not valid.at System.Drawing.Bitmap..ctor(Stream stream)” in my code. I am using the Following lines in my code,System.Drawing.Bitmap image = new System.Drawing.Bitmap(fileUpload1.PostedFile.InputStream);I don’t find anything wrong in this code.why i am getting this exception? How to solve?Please help me!!Thanks!!
Brian
java stream inputstream classcastexception recover
I’m writing a server and I’m using an ObjectInputStream to handle proprietary packets. I’ve recently been sometimes getting some unexpected ClassCastExceptions when I want call objectInputStream.readObject() and then trying casting them into the proprietary packets. I’ve been trying to trace the problem and I’ve been wondering whether it’s because the objectInputStream is crashing due to some problem. According to the documentation for the method objectInputStream.readObject()… “All exceptions
Web site is in building