google login
I am working on php . I have made app on Google . If u can see my link , I am using state parameter , in which state=reg . In my callback page , I am trying to get this value ie $_get['state'] but its not showing me anything . Am i doing the right way ?
I've never seen a Client ID that begins "**", but in your link I see client_id=%2a%2a43760%2a%2a%2a%2a%2a-cp7 which really looks wonky. Are you sure that’s right?
Related
I've been developing a news letter system locally and everything works fine . The mystery begun when I uploaded the whole content to my server , I could see the index page but when I enter the username / Password to log in (in the index page), I get redirected to "authenticate.php " where the Post data are processed this way :
<?php include("includes/initialize.php");
if(!isset($_POST['username']) OR !isset($_POST['password']))
{
// no data were given
redirect_to("error.php");
}
elseif(!$user = User::authenticate($_POST['username'],$_POST['password']))
{
// user not found in the database
redirect_to("error.php");
}
else {
$session->login($user);
redirect_to("enewsletter.php");
}
?>
On this page I get stuck (not on localhost ) , the server is rendering a blank page . after some tests , I tell you what happens : If I fall in the if situation i get redirected to error.php , but when I enter some credentials , It's doing nothing :/
So I added an echo statement to keep trace of the code :
and I had this remark, every time the script meets to a line containing a method that looks in the database (OOP approach) the server is always rendering blank pages , I tried it on many pages and it's always the same . I changed the database connection type from PDO to mysqli (because I thought the server is not supporting PDO) but no change !!
Does any one has a clue , what could be the reason?
well ,
it was just a " Self instead of self " problem ...
Thank you all for your help ;)
I asked the same question earlier and it got down voted and I have no idea why. I'm building a class that outputs a news feed, but it's a very structured html that I'm going to use a lot on the site (hundreds of times), so I'm using a class method to display the feed html and everything. And I just echo the whole thing.
The method is set up this way:
private function feed ($var)
{
$Statement = $this->Database->prepare("SELECT * FROM feed WHERE col = ? ORDER BY timestamp DESC LIMIT 50");
$Statement->execute(array($var));
while ($row = $Statement->fetch(PDO::FETCH_ASSOC))
{
echo ' <div class="feed-box">
' . /*facebook name retrieved from the facebook */ . '
' . $row["post"] . '
<br/>
</div>';
}
} //end feed
The class is set up so that another method that has more of the html template calls this feed method. (I'm not trying to be too redundant here, but again the last time I asked this question it got down voted). So I'm pretty new to oop, and I'm looking to display the profile pictures of people who are logged in with facebook. This isn't necessarily a facebook question because I know how to do it normally, but I don't know how to get the facebook information within the class scope using just their id. Normally I;d get their picture by going linking to this url https://graph.facebook.com//picture. How do I do this within the class when I only sotre their facebook id in the database? I've been working on this problem for a couple days now, and I can't figure it out on my own. So I really appreciate your help.
It's getting to the point where I just want to statically type everything out because I know I could easily do that, but I'd really love to learn what the proper way is, especially since editing so many of these little boxes if I want to change something one day would be a real hassle. Thanks for your help. I really appreciate it. Let me know if anything is unclear I'll update the questino as soon as I can.
How do I do this within the class when I only sotre their facebook id in the database
echo '<img src="https://graph.facebook.com/' . $row['facebook_id'] . '/picture" />' ;
You say you only store the facebook id in your database. That is all you need to display the picture. Just append /picture to the user's FB graph link to get the picture.
I have any adress recorded in my databse corresponding to the customers.
The trouble I met is concerning the including of a googlemap.
I have the following code that convert an adress to the polares.
function getCoordonnees($adresse) {
$url = "http://maps.google.com/maps/geo?q=" . urlencode($adresse) .
"&output=csv";
$csv = file($url);
$donnees = preg_split("#,#", $csv[0]);
return $donnees[2] . "," . $donnees[3];
}
The following code returns to me somethinbg like that
48.9381235,2.1329083
When I use the google map I have a picture like that :
Which comes from this url (generated by my function
http://maps.google.com/staticmap?center=48.9381235,2.1329083&zoom=15&size=300x300&maptype=mobile&markers=48.9381235,2.1329083,red&key=***********************KEY*GOOGLEMAP************&sensor=false
When I try to display that picture in my website, An error appears,
<img src="http://maps.google.com/staticmap?center=<?php echo $polar; ?>&zoom=15&size=300x300&maptype=mobile&markers=<?php echo $polar; ?>,red&key=***********************KEY*GOOGLEMAP************&sensor=false" style="border:double 2px" />
Where $polar is the polares.
Including this code in my website returns to me the following mistake :
Failed to load resource: the server responded with a status of 403 (Forbidden)
I have no idea from where comes this error. Actualy I do not think it comes from google map because on stackoverflow, the picture is displayed.
So I would ask if anybody know where can comes this mistake ? Is is from the server configuration or something else ? I've been looking for that since many times without answer.
Anykind of help will be much appreciated.
I was having the same issue and I decided to turn on Google Maps API v2
I already had Google Maps API v3 on but before messing with to many settings I turned them both on.
Now it works
I was wondering if it was possible to use PHP / AJAX to have a string of text sharable to Facebook? For example, I use PHP to return an SQL query, then use that same string of text in correspondence with a button, to share to my Facebook wall. So, it might look something like this in the PHP:
while($note_row = mysql_fetch_row($result)) {
echo '<p> "' . $note_row['my_note_text'] . ' "</p>';
echo '<input type="button" id="' . $note_row['my_note_id'] . '" class="share-to-facebook" value="share" />';
}
If anyone has some advice whether this is possible I'd be super happy. I also apologise if my PHP is wrong, I haven't checked it.
You have some options:
sharer.php
https://www.facebook.com/note.php?note_id=407822831963
Create a share link. You can set title and url.
Feed Dialog
https://developers.facebook.com/docs/reference/dialogs/feed/
Creates a share dialog. More options for description and image etc. Might be a replacement for sharer.php.
If you need to post to the wall from your app, you need the get permissions by having the user accept your app to Facebook. Read more about authentication at https://developers.facebook.com/docs/authentication/
First things first. I'm running CodeIgniter on a PHP/MySQL site.
I've been tasked with creating a "shell" application for a series of movies that a person can view for a training website that I'm building. The idea here is that a person would be able to log on to a page, click "Take Course" and have it log what time the course was taken. Then, when the person exits the page carrying the movie, I would be able to record what time the course was ended. This way I can compare the start and end times, and determine if the user had viewed most of the film in order to give the user credit. Well, the first part is easy. First, I've built a table in my database with the following fields:
intKey (intKey(10))
strHash (varchar(255))
dtBegan (datetime)
dtEnded (datetime)
varIpAddress (varchar(255))
I've put in a controller that does this:
$ip_address = $_SERVER['REMOTE_ADDR'];
$data['hash'] = md5(time() . "Proof of Concept!");
$this->db->query("INSERT INTO pocTime SET strHash = '" . $data['hash'] . "', dtBegan = now(), varIpAddress='$ip_address'");
$this->load->view('welcome_message',$data);
OK... easy enough, yes? I also know that when I am done, I want to launch a file that does this:
$ip_address = $_SERVER['REMOTE_ADDR'];
$this->db->query("UPDATE pocTime SET dtEnded = now() WHERE strHash = '" . $data['hash'] . "' AND varIpAddress='$ip_address'");
What I'm hoping to do is have a page that is called by the 1st block of code, and set a "trap" so to speak so that the 2nd block of code is run by some kind of "post back" if the rendered page is closed. Any suggestions? I know that I could put some sort of big "CLICK HERE TO END YOUR VIDEO" type button that would cover this, but I'm looking to run code on some form of exit from a page, because I don't know what the user would do after viewing the video. Any thoughts?
Simple but should work, using jQuery
$(window).unload(function(){
$.get("test.php?dim1=turn&dim2=off");
});
Using unload which jQuery documentation tells what triggers this:
http://api.jquery.com/unload/
Using get which jQuery documentation is here:
http://api.jquery.com/get/
Or you can use post as well
$(window).unload(function(){
$.post("test.php", { dim1: "turn", dim2: "off" } );
});
http://api.jquery.com/jQuery.post/
You are looking for jQuery's unload event.
I would also recommend that you use Codeigniter's Active Record Syntax in your database queries. Not only does it make writing INSERT and UPDATE queries much easier, it will also escape and sanitize your input to protect you from SQL injection.