PHP - Moved: Google Data Api In Php
This topic has been moved to Other Libraries and Frameworks.
http://www.phpfreaks.com/forums/index.php?topic=307094.0 Similar TutorialsHi all i was wondering if someone with exp in youtube api could help me out with this I have a website where i want to let people subscribe to others and first off i auth the user Code: [Select] session_start(); set_include_path('path'); require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path Zend_Loader::loadClass('Zend_Gdata_YouTube'); $yt = new Zend_Gdata_YouTube(); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); function getAuthSubRequestUrl() { $next = 'my site'; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); } function getAuthSubHttpClient() { if (!isset($_SESSION['sessionToken']) && !isset($_GET['token']) ){ echo '<a href="' . getAuthSubRequestUrl() . '">Login!</a>'; return; } else if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $httpClient; } And that takes me to the page to auth my account, then when i go back to my website and hit the sub button that i made Code: [Select] <?php $username = $_SESSION['username']; include("connect.php"); $mysql = mysql_query("SELECT * FROM users WHERE username = '$username'"); while($row = mysql_fetch_assoc($mysql)){ ?> <table> <tr><td> <?php echo $row['channel']; ?> </td></tr> <tr><td> <form action="sub4sub.php?id=<?php echo $row['id']; ?>" method="POST"> <input type="submit" name="i" value="Sub"> </form> </td></tr></table> <?php } if (isset($_POST['i'])){ $id = $_GET['id']; $sql = mysql_query("SELECT * FROM users WHERE id= $id"); $row = mysql_fetch_assoc($sql); $ytkb = $row['channel']; // this example assumes that $yt is a fully authenticated service object getAuthSubHttpClient(); $subscriptionsFeedUrl = "http://gdata.youtube.com/feeds/api/users/default/subscriptions"; $newSubscription = $yt->newSubscriptionEntry(); $channel = $ytkb; $newSubscription->setUsername(new Zend_Gdata_YouTube_Extension_Username($channel)); // post $yt->insertEntry($newSubscription, $subscriptionsFeedUrl); } ?> So should be subscribing to the persons channel that is displayed in the table, but i get this errors Quote Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401 <HTML> <HEAD> <TITLE>User authentication required.</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>User authentication required.</H1> <H2>Error 401</H2> </BODY> </HTML> ' in /home/u292976682/public_html/Zend/library/Zend/Gdata/App.php:709 Stack trace: #0 /home/u292976682/public_html/Zend/library/Zend/Gdata.php(221): Zend_Gdata_App->performHttpRequest('POST', 'http://gdata.yo...', Array, '<atom:entry xml...', 'application/ato...', NULL) #1 /home/u292976682/public_html/Zend/library/Zend/Gdata/App.php(900): Zend_Gdata->performHttpRequest('POST', 'http://gdata.yo...', Array, '<atom:entry xml...', 'application/ato...') #2 /home/u292976682/public_html/Zend/library/Zend/Gdata/App.php(975): Zend_Gdata_App->post(Object(Zend_Gdata_YouTube_SubscriptionEntry), 'http://gdata.yo...', NULL, NULL, Array) #3 /home/u292976682/public_html/sub4sub.php(123): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_YouTube_Subscrip in /home/u292976682/public_html/Zend/library/Zend/Gdata/App.php on line 709 Any help would be great thanks Hi,
I have a php script that generates a select dropdown box
<option value="1"> Bob </option>
<option value="2"> Tim </option>
<option value="3"> Sam </option>
<option value="4"> Phil </option>
I then have the following javascript to produce my google api graph:
<script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "test1.php", dataType:"json", async: false, }).responseText; var data = new google.visualization.DataTable(jsonData); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data); } </script>This then runs a php script that returns the data back in Json format. How can I pass the <option value=""> through the to the test1.php script to generate the json data based on the the value selected i.e 1, 2, 3 etc. i an new at javascript and the google api can anyone let me know how I can get this variable sent through by the google api script. and for the graph to refresh every time another option is chosen. Thanks kris This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=344076.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=315333.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=321605.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=356960.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333650.0 Hey all, Let's say if all of the data in the site is the result of queries from the database that are output as html by php as users interact with the site. For example, there's no home.php file. Rather user clicks the link to view the page, and a php script pulls data from database and renders the page at that time. There is no javascript involved in this process. Would this page be crawlable by google? Thanks for response. i've to populate google charts with dynamic data. the data looks llike. +----+-------+---------+-------+-----------+---------+------+ | id | name | physics | maths | chemistry | biology | sst | +----+-------+---------+-------+-----------+---------+------+ | 1 | Name1 | 10 | 25 | 35 | 42 | 62 | | 2 | Name2 | 80 | 45 | 45 | 45 | 25 | | 3 | Name3 | 63 | 25 | 63 | 36 | 36 | | 4 | Name4 | 82 | 36 | 75 | 48 | 42 | | 5 | Name5 | 45 | 45 | 78 | 25 | 24 | | 6 | Name6 | 36 | 36 | 15 | 75 | 36 | | 7 | Name7 | 99 | 45 | 24 | 24 | 45 | | 8 | Name8 | 45 | 85 | 85 | 85 | 96 | +----+-------+---------+-------+-----------+---------+------+ i have to create google charts based on this such that # namewise - such that when i select a name it displays all subject marks of that particular name in a column chart #markswise - when i select a subject, it displays all the names with marks in that particular subject. conisdiering that data may be added and i've to accumulate that also, for namewise i did // chart.php <?php include("connection.php"); $query = "SELECT name FROM csv GROUP BY name DESC"; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); ?> <!DOCTYPE html> <html> <head> <title>Google charts</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> </head> <body> <br /><br /> <div class="container"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-9"> <h3 class="panel-title">Student Wise Marks Data</h3> </div> <div class="col-md-3"> <select name="name" class="form-control" id="name"> <option value="">Select Student</option> <?php foreach($result as $row) { echo '<option value="'.$row["name"].'">'.$row["name"].'</option>'; } ?> </select> </div> </div> </div> <div class="panel-body"> <div id="chart_area" style="width: 1000px; height: 620px;"></div> </div> </div> </div> </body> </html> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(); function load_student_data(name, title) { var temp_title = title + ' '+name+''; $.ajax({ url:"fetch.php", method:"POST", data:{name:name}, dataType:"JSON", success:function(data) { drawStudentwiseChart(data, temp_title); } }); } function drawStudentwiseChart(chart_data, chart_main_title) { var jsonData = chart_data; var data = new google.visualization.DataTable(); data.addColumn('number', 'Physics'); data.addColumn('number', 'Maths'); data.addColumn('number', 'Chemistry'); data.addColumn('number', 'Biology'); data.addColumn('number', 'SST'); $.each(jsonData, function(i, jsonData){ var Physics = jsonData.Physics; var Maths = jsonData.Maths; var Chemistry = jsonData.Chemistry; var Biology = jsonData.Biology; var SST = jsonData.SST; data.addRows([[Physics,Maths,Chemistry,Biology,SST]]); }); var options = { title:chart_main_title, hAxis: { title: "Subjects" }, vAxis: { title: 'Percentage' } }; var chart = new google.visualization.ColumnChart(document.getElementById('chart_area')); chart.draw(data, options); } </script> <script> $(document).ready(function(){ $('#name').change(function(){ var name = $(this).val(); if(name != '') { load_student_data(name, 'Student wise marks data'); } }); }); </script> and in order to fetch data // fetch.php <?php //fetch.php include('connection.php'); if(isset($_POST["name"])) { $query = " SELECT * FROM csv WHERE name = '".$_POST["name"]."' ORDER BY id ASC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { $output[] = array( 'Physics' => $row["Physics"], 'Maths' => $row["Maths"], 'Chemistry' => $row["Chemistry"], 'Biology' => $row["Biology"], 'SST' => $row["SST"], ); } echo json_encode($output); } ?> it diplays a blank page. however when i play with singular values i.e one subject at a time it displays fine Edited March 19, 2019 by zetastreakThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=307157.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=357315.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=328756.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=356052.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=306254.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=351914.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=356789.0 Hi Guys.... I need to export data into excel file. So far its works on IE and Firefox. But if i using Google Chrome it download only php file. Eg(suppose file test.xls but it goes to test.php). Why it happen?? This topic has been Ctrl+X/Ctrl+V'd to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347400.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346255.0 |