Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include 'includes/db.conn.php';
- include 'includes/functions.php';
- ?>
- <?php
- //callback URL
- $url = "http://www.SwingAcademy.com/web/external/api.ashx?method=getLessons&callback=?";
- //your Group ID
- $groupID = "43AB3367-F58D-487E-B2C6-2571A3A3508C";
- //custom variables, will change in live site
- $num_results = "";
- $instructor_id = "3788";
- $owner_id = "3788";
- $lesson_group_id = "6";
- //post varaibles in an array back to API to receive response
- $post_data = array (
- "NUMRESULTS" => $num_results,
- "GROUPID" => $groupID,
- "OWNERID" => $owner_id,
- "INSTRUCTORID" => $instructor_id
- );
- //////////////////////////////////////
- //////////////////////////////////////
- //do not edit below this line/////////
- //////////////////////////////////////
- //////////////////////////////////////
- $curl_options = array(
- CURLOPT_URL => $url ,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => http_build_query( $post_data ),
- CURLOPT_HTTP_VERSION => 1.0,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_HEADER => false
- );
- $curl = curl_init();
- curl_setopt_array( $curl, $curl_options );
- $result = curl_exec( $curl );
- //un comment to show returned data in JSONP format, we need to convert it to JSON
- //for PHP to like it.
- //echo $result;
- //convert JSONP to JSON here
- function jsonp_decode($jsonp, $assoc = false) { // PHP 5.3 adds depth as third parameter to json_decode
- if($jsonp[0] !== '[' && $jsonp[0] !== '{') { // we have JSONP
- $jsonp = substr($jsonp, strpos($jsonp, '('));
- }
- return json_decode(trim($jsonp,'();'), $assoc);
- }
- //check JSON for any errors
- switch (json_last_error()) {
- case JSON_ERROR_NONE:
- echo ' - No errors';
- break;
- case JSON_ERROR_DEPTH:
- echo ' - Maximum stack depth exceeded';
- break;
- case JSON_ERROR_STATE_MISMATCH:
- echo ' - Underflow or the modes mismatch';
- break;
- case JSON_ERROR_CTRL_CHAR:
- echo ' - Unexpected control character found';
- break;
- case JSON_ERROR_SYNTAX:
- echo ' - Syntax error, malformed JSON';
- break;
- case JSON_ERROR_UTF8:
- echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
- break;
- default:
- echo ' - Unknown error';
- break;
- }
- //uncomment this to show errors in JSON
- //echo PHP_EOL;
- //echo JSON data
- //echo "<pre>";
- //var_dump(jsonp_decode($result, true));
- //echo "</pre>";
- //assign JSON data
- $arrResult = jsonp_decode($result, true);?>
- <div class="row">
- <div class="span2">......</div>
- <div class="span7">
- <h1 class="red-font">Your Prior Reviews</h1>
- <?
- /////////////////////////////////////////////////
- //////////////////// do not edit above this line/
- /////////////////////////////////////////////////
- /////////////////////////////////////////////////
- //query our DB for instructor information
- $query_in ="SELECT instructor_email, first_name, last_name, user_id, rst_level FROM swing_instructors WHERE user_id=?";
- if ($stmt1 = $mysqli->prepare($query_in)) {
- $stmt1->bind_param("i", $instructor_id);
- $stmt1->execute();
- /* bind result variables */
- $stmt1->bind_result($instructor_email, $first_name, $last_name, $instructor_id, $rst_level);
- /* fetch values */
- while ($stmt1->fetch()) {
- $instructor_email;
- $first_name;
- $last_name;
- $instructor_id;
- $rst_level;
- }
- }
- //query our DB for lesson information, correlate with info from API calls
- $query ="SELECT instructor_id, lesson_comments, user_id, lesson_date, video_ids, lesson_id FROM swing_viewer_lessons WHERE instructor_id=? and user_id=?";
- if ($stmt = $mysqli->prepare($query)) {
- $stmt->bind_param("ii", $instructor_id, $owner_id);
- $stmt->execute();
- /* bind result variables */
- $stmt->bind_result($instructor_id, $lesson_comments, $owner_id, $lesson_date, $video_ids, $lesson_id);
- /* fetch values */
- while ($stmt->fetch()) {
- //convert video id array to single lines
- $pieces = explode(",", $video_ids);
- //$pieces[0]; // piece1
- //$pieces[1]; // piece2
- //$pieces[2]; // piece3
- //iterate through API information
- foreach($arrResult['VIDEOS'] as $p){
- //convert epoch to date Y-M-D format
- $epoch = $p['LESSONDATE'] ;
- $dt = new DateTime("@$epoch"); // convert UNIX timestamp to PHP DateTime
- //check to make sure both lesson IDs match from API and our DB
- if($lesson_id == $p['LESSONID']){?>
- <div class="lessonHolder">
- <p style="font-size: 16px;"><strong>Instructor Title</strong></p>
- <p><?php echo $dt->format('m/d/y g:ia'); // output = 2013-08-15 ?>
- <?php echo $first_name;?>
- <?php echo $last_name;?>,
- <?php echo $rst_level;?>
- </p>
- <?php //echo $instructor_email;?>
- <div class="span3">
- <?php
- if($p['THUMBNAIL'] == NULL){
- echo "<a href=\"#myModal_".$lesson_id."\" data-toggle=\"modal\"><img src=\"http://placehold.it/250x150\"/></a>";
- }
- else
- {
- echo "<a href=\"#myModal_".$lesson_id."\" role=\"button\" class=\"btn\" data-toggle=\"modal\"><img src=".$p['THUMBNAIL']."/></a>";
- }?>
- <a href="lessons.php?lessonID=<?php echo $lesson_id ;?>" style="margin-top: 10px;width:210px;" class="btn btn-success btn-large">Click to Watch Review</a>
- </div>
- <div class="span3">
- <h3>Your Lesson Notes</h3>
- <?php if($p['NOTES'] == NULL){
- echo "You did not include any notes with the lesson request.<br/><br/>";
- }else{
- echo $p['NOTES'];
- }
- ?>
- <h3>Recommended Videos:</h3>
- <?php
- //iterate through video IDS in our DB
- foreach ($pieces as $key) {
- echo $key;
- $query4 ="SELECT id, video_name, link, phase FROM videos WHERE id=$key";
- if ($stmt4 = $mysqli->prepare($query4)) {
- $stmt4->execute();
- /* bind result variables */
- $stmt4->bind_result($id, $vid_name, $vid_link, $phase);
- /* fetch values */
- while ($stmt4->fetch()) {
- echo "<input type='checkbox' name='checkbox[]' id='$id' value='$id' />";
- echo "<a href='http://www.rotaryswing.com/golf-instruction/video/rst-index.php?cat=$phase&subcat=Rotary%20Swing%20Tour&video=$id&id=$vid_link&name=$vid_name' target=\"blank\">" .$vid_name. "</a><br>";
- }
- }
- }
- ?>
- <?php echo $lesson_id . "<br/>";?>
- <!-- Modal -->
- <div id="myModal_<?php echo $lesson_id;?>" style="display: none;" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3 id="myModalLabel">Modal header</h3>
- </div>
- <div class="modal-body">
- <p> <iframe src="<?php echo $p['VIDEOURL'];?>" width="800px" height="470px"></iframe>
- </p>
- </div>
- <div class="modal-footer">
- <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
- </div>
- </div>
- </div>
- </div>
- <?php }}}} ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment