Instagram's geotagging API - api

I'm working on learning about Instagram's API as a side project. I've followed this tutorial (http://eduvoyage.com/instagram-search-app.html) to implement a search feature by hashtag. It was extremely helpful to me. One of the things I saw in the API was the location ID feature, and I was wondering how to implement that. Through a search on this site, I found that a request can be made which will return the following.
'{
"meta": {
"code": 200
},
"data": {
"attribution": null,
"tags": [],
"type": "image",
"location": {
"latitude": 48.8635,
"longitude": 2.301333333
},
"comments": {
"count": 0,
"data": []
},
..........'
I'm trying to figure out this tutorial to process that information. (http://www.ibm.com/developerworks/xml/library/x-instagram1/index.html#retrievedetails)
<html>
<head>
<style>
</head>
<body>
<h1>Instagram Image Detail</h1>
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
// define consumer key and secret
// available from Instagram API console
$CLIENT_ID = 'YOUR-CLIENT-ID';
$CLIENT_SECRET = 'YOUR-CLIENT-SECRET';
try {
// define image id
$image = '338314508721867526';
// initialize client
$client = new Zend_Http_Client('https://api.instagram.com/v1/media/' . $image);
$client->setParameterGet('client_id', $CLIENT_ID);
// get image metadata
$response = $client->request();
$result = json_decode($response->getBody());
// display image data
?>
<div id="container">
<div id="info">
<h2>Meta</h2>
<strong>Date: </strong>
<?php echo date('d M Y h:i:s', $result->data->created_time); ?>
<br/>
<strong>Creator: </strong>
<?php echo $result->data->user->username; ?>
(<?php echo !empty($result->data->user->full_name) ?
$result->data->user->full_name : 'Not specified'; ?>)
<br/>
<strong>Location: </strong>
<?php echo !is_null($result->data->location) ?
$result->data->location->latitude . ',' .
$result->data->location->longitude : 'Not specified'; ?>
<br/>
<strong>Filter: </strong>
<?php echo $result->data->filter; ?>
<br/>
<strong>Comments: </strong>
<?php echo $result->data->comments->count; ?>
<br/>
<strong>Likes: </strong>
<?php echo $result->data->likes->count; ?>
<br/>
<strong>Resolution: </strong>
<a href="<?php echo $result->data->images
->standard_resolution->url; ?>">Standard</a> |
<a href="<?php echo $result->data->images
->thumbnail->url; ?>">Thumbnail</a>
<br/>
<strong>Tags: </strong>
<?php echo implode(',', $result->data->tags); ?>
<br/>
</div>
<div id="image">
<h2>Image</h2>
<img src="<?php echo $result->data->images
->low_resolution->url; ?>" /></a>
</div>
<div id="comments">
<?php if ($result->data->comments->count > 0): ?>
<h2>Comments</h2>
<ul>
<?php foreach ($result->data->comments->data as $c): ?>
<div class="item"><img src="<?php echo $c
->from->profile_picture; ?>" class="profile" />
<?php echo $c->text; ?> <br/>
By <em> <?php echo $c->from->username; ?></em>
on <?php echo date('d M Y h:i:s', $c->created_time); ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
<?php
} catch (Exception $e) {
echo 'ERROR: ' . $e->getMessage() . print_r($client);
exit;
}
?>
</body>
</html>
The main problem (I think) that I'm having is here:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
I downloaded Zend Frame 1.12.13, but I'm not sure what these line of code is asking for. In the Zend Framework folder, It goes "Zend/Loader(Folder)", but nothing called "Loader.php". Does that just load everything in the 'Loader' folder? Same for the Zend_Loader, there is a directory of Zend/Http/Client, but Client is also a folder.
tl;dr
Trying to set up a program that will search instagram (as linked in the tutorial above), be able to click on the picture results, open one tab that shows the picture and the users profile, and another tab that shows all the image metadata. Is there a simpler way to do this? Or a more noob friendly tutorial?

I ran into a similar problem when using this example. You must include the path of the Zend framework at the very top of this example. I did it in just its own php block at the top.
ini_set('include_path', 'path/to/ZendFramework/library');

Related

use of email format in yii

I am able to send simple email to receiver.Now i have to be able to select a email format from existing different formats and this template must appear in my message box.i should also be able to change the content of the template that appears in message box before sending to receiver.How to do this?
My code for view form
<div class="form wide">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'mail-form',
'enableAjaxValidation'=>true,
'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS
)); ?>
<div class="row col2">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div class="row col2">
<?php echo $form->labelEx($model,'subject'); ?>
<?php echo $form->textField($model,'subject',array('size'=>60,'maxlength'=>250)); ?>
<?php echo $form->error($model,'subject'); ?>
</div>
<div style="clear:both"></div>
<div class="row col2">
<?php echo $form->labelEx($model,'message'); ?>
<?php echo $form->textArea($model,'message',array('style'=>'width: 680px; height: 300px;')); ?>
<?php echo $form->error($model,'message'); ?>
</div>
<div style="clear:both"></div>
<div class="row buttons">
<?php
echo CHtml::submitButton($model->isNewRecord ? 'Send' : 'Send',array('class' => 'btn'));
?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Try below code:
public function actionContact() {
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$status = Yii::$app->mailer->compose()
->setTo($model->email_to)
->setFrom([$model->email_from => $model->email_from])
->setSubject($model->subject)
->setTextBody($model->message)
->send();
if ($status) {
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending email.');
}
return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}
}
You can also create a email_template directory under views folder and create template file in which you can set email template content.
you can use js or ajax to do the same.
1: Use jQuery:
I assume that you are using jQuery. So use ajax.
.......JS Cod........
/*I assume that you have your template data in an attribute like data-template-data=""*/
$('#select_template_id').chang(function(){
template=$(this).attr('data-template-data');
$('#template_edit_box').val(template);
});

dijit.layout.ContentPane shifts right on page load

I have a problem which I am unable to fix, maybe somebody can help?
I have a dijit.layout.ContentPane at the top of my page, this sits in a dijit.layout.BorderContainer. On page load the contents of the container shift right and down by about 15px. All other elements work fine.
I have isolated the issue to dijit.layout.ContentPane. In side the container I am running some php if statements and drawing some simple buttons:
<!-- Here are the common buttons above the tabs -->
<div id="toolPane" dojoType="dijit.layout.ContentPane" region="top" >
<?php
if($this->restrict == 1){
if($this->teammembers == 1 || $this->newleaders == 1 || $this->newadminleaders == 1){
if ($this->mayUpdateSummary){
?><span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue, 'Create report', 'report', 'reportLink'); ?></span>
<span style="white-space:nowrap;" ><a class="emailLink" href="mailto:?subject=Task%20%23<?php echo $issue->id; ?>&body=<?php echo urlencode($this->serverUrl(true)); ?>">Share link</a></span><?php
}
}
}else if($this->restrict == 2){
if ($this->mayUpdateSummary){
?><span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue, 'Create report', 'report', 'reportLink'); ?></span>
<span style="white-space:nowrap;" ><a class="emailLink" href="mailto:?subject=Task%20%23<?php echo $issue->id; ?>&body=<?php echo urlencode($this->serverUrl(true)); ?>">Share link</a></span><?php
}
}
?>
<?php if ($this->mayUpdateSummary): ?>
<span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue,'Edit summary', 'progress-summary', 'editbutton'); ?></span>
<?php endif; ?>
<?php if ($closeButton): ?>
<span style="white-space:nowrap;" ><?php echo $closeButton; ?></span>
<?php endif; ?>
<?php if ($reopenButton): ?>
<span style="white-space:nowrap;" ><?php echo $reopenButton; ?></span>
<?php endif; ?>
</div>
Ok, we have decided to hide the page until the dijit elements have loaded. To do this we have added this script which fades in the page giving it time to sort itself out before it is displayed:
<script type="text/javascript">
$(document).ready(function(){
$(".content").hide();
});
$(window).load(function(){
$(".content").fadeIn("fast");
});
</script>
<div class="content">
[faded in content goes here]
</div>

run time watermark generate on pdf file Yii framework

" i have uploaded a file on server i want when a user from my website download this file he should be a watermarked file (watermark text will be 'his email id' in pdf file) "
Controller:
public function actionDownloadFiles()
{
ignore_user_abort(true);
$path = ( Yii::app()->basePath.'/../images/prequlification_form/'.$_GET['path'] );
$fullPath = $path ;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
}
View:
<h3><p class="note"><span class="required">form</span> Filling is required.</p></h3>
<?php echo $form->errorSummary($model); ?>
<!--here is the user id-->
<?php //echo $id;?>
<div class="file-dwnload">
<?php
$data=prequalificationForm::model()->findByPk(1);
if(!empty($data)) {
echo '<div class="dwnload-file"><li>'.
CHtml::link( $data->file_path,array("prequalificationForm/downloadFiles","path"=>($data->file_path))).
'</li></div> <div class="dwnload-butn"><li>'.
CHtml::link('Download File',array("prequalificationForm/downloadFiles","path"=>($data->file_path)))
."</li></div> " ;
}?></div>
<div class="row">
<?php echo $form->labelEx($model,'file_path'); ?>
<?php echo $form->fileField($model,'file_path',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'file_path'); ?>
</div>
<div class="row buttons">
<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Save',array('class'=>'submit-btn')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
So you want to watermark the pdf with some data from the user.
You would have some options to do that.
The easier would be if you don't do it on a uploaded file, instead you generate html content and convert html to pdf on the fly.
But if you need to do it on a uploaded file, maybe this could help you:
Writing/Drawing over a PDF template document in PHP

want to implement the desoslider in my website

my web site is using osclass classified script and i want to implement the desoslider in my website and i followed the [http://sylouuu.github.io/desoslide/documentation.html#setup][1]
the code and script i have used is below
PHP
<?php if( osc_images_enabled_at_items() ) { ?>
<?php if( osc_count_item_resources() > 0 ) { ?>
<div id="photos">
<?php for ( $i = 0; osc_has_item_resources(); $i++ ) { ?>
<a href="<?php echo osc_resource_url(); ?>" rel="image_group" title="<?php _e('Image', 'modern'); ?> <?php echo $i+1;?> / <?php echo osc_count_item_resources();?>">
<?php if( $i == 0 ) { ?>
<img src="<?php echo osc_resource_url(); ?>" width="70" height="50" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>" />
<?php } else { ?>
<img src="<?php echo osc_resource_thumbnail_url(); ?>" width="70" height="50" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>" />
<?php } ?>
</a>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
<div id=demo></div>
JS
$(function() {
$('#photos').desoSlide({
main: {
container: '#demo',
cssClass: 'img-responsive'
},
caption: true
});
});
the document says that we have to specify your images links and the alt attribute. i tried several steps but no success. help me to successfully use this desoslider
Because in 1.* versions your thumbnails must be inside an <ul> tag with <li>. So replace <div id="photos"> by <ul id="photos"> and wrap <a> within <li>.
But anyway, this mandatory markup structure has been changed, the version 2 is more permissive. Check it out: http://sylouuu.github.io/desoslide/doc/

Yii - Error 400 The CSRF token could not be verified

I have a very strange problem. I have a login form in Yii which works fine. After moving the website to another server I get
Error 400 The CSRF token could not be verified
I don't understand why it is working on the development server but not on the new server. here is my code:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>
and here is the csrf configuration in my config file:
'enableCsrfValidation' => !isset($_POST['dontvalidate']) ? true : false,
if you need to see the example. Here is the one which is working, and here is the one with the problem
I opened the first example and found this html in source, This is correct.
<input type="hidden" value="df5a0fc9ab86f85cdcdabe6b2ee62e85d3ac0323"
name="YII_CSRF_TOKEN" />
on the second example page, I haven't found any html code as above. That means enableCsrfValidation is set to false in second example.
try debugging $_POST['dontvalidate'] in this page (or in config/main.php ).