Hello everyone I wonder if someone could help me with this issue I have been using the Twitter API class for over a year now fine. Last week I moved to a grid hosting plan from shared hosting now everytime I use the API get the following errors.
Uncaught exception 'EpiOAuthException' in /home/content/98/3412598/html/twitter/EpiOAuth.php:434 Stack trace:
#0 /home/content/98/3412598/html/twitter/EpiOAuth.php(404): EpiOAuthException::raise(Object(EpiCurlManager), false)
#1 /home/content/98/3412598/html/twitter/EpiOAuth.php(45): EpiOAuthResponse->__get('oauth_token')
#2 /home/content/98/3412598/html/twitter/ufollowme.php(13): EpiOAuth->getAuthenticateUrl() #3 {main} thrown in /home/content/98/3412598/html/twitter/EpiOAuth.php on line 434
I am using this library http://code.google.com/p/php-twitter/downloads/detail?name=php-twitter-1.1.zip&can=2&q=
and here is the simpletest code which I have used all along.
include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
$consumer_key = 'REMOVED';
$consumer_secret = 'REMOVED';
$token = 'REMOVED';
$secret= 'REMOVED';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
$twitterObjUnAuth = new EpiTwitter($consumer_key, $consumer_secret);
?>
<h1>Single test to verify everything works ok</h1>
<h2>View the source of this file</h2>
<div id="source" style="display:none; padding:5px; border: dotted 1px #bbb; background-color:#ddd;">
<?php highlight_file(__FILE__); ?>
</div>
<hr>
<h2>Generate the authorization link</h2>
<?php echo $twitterObjUnAuth->getAuthenticateUrl(); ?>
<hr>
<h2>Verify credentials</h2>
<?php
$creds = $twitterObj->get('/account/verify_credentials.json');
?>
<pre>
<?php print_r($creds->response); ?>
</pre>
<hr>
<h2>Post status</h2>
<?php
$status = $twitterObj->post('/statuses/update.json', array('status' => 'This a simple test from twitter-async at ' . date('m-d-Y h:i:s')));
?>
<pre>
<?php print_r($status->response); ?>
</pre>
<script> function viewSource() { document.getElementById('source').style.display=document.getElementById('source').style.display=='block'?'none':'block'; } </script>
Any help welcomed. Thank you
Found the fix guys if anyone else needs to answer its remove lines 171-172 on the EPIOAUTH.php file.
// if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1')
// curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']);
Related
I am using Mpdf which is working fine locally, the trouble I am having is that the pdf wont output and just get a blank screen
Here is the error
Fatal error: Uncaught Mpdf\MpdfException: Data has already been sent to output (/customers/3/c/2/includes/header.php at line 14), unable to output PDF file in /customers/3/c/2/pdf/vendor/mpdf/mpdf/src/Mpdf.php:9510 Stack trace: #0 /customers/3/c/2: Mpdf\Mpdf->Output('sold.pdf', 'I') #1 /customers/3/c/2/include('/customers/3/c/...') #2 {main} thrown in /customers/3/c/2/pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 9510
Couple of things I have tried, encoding is correct at UTF and NOT DOM, I have no white space, and everything seems to be ok
This is the header code
<?php
session_start();
if(empty($_SESSION['user_id']))
{
header("Location: https://www.home.co.uk");
}
require '../dbcon/database.php';
$db = DB();
require '../lib/library.php';
$app = new WIDGET();
require '../lib/carbon.php';
$user = $app->UserDetails($_SESSION['user_id']);
?>
I have also tried
<?php
session_start();
require '../dbcon/database.php';
$db = DB();
require '../lib/library.php';
$app = new WIDGET();
require '../lib/carbon.php';
$user = $app->UserDetails($_SESSION['user_id']);
?>
Which has made no difference.
And this is the code in line 9510 of Mdpf.php
case Destination::INLINE:
if (headers_sent($filename, $line)) {
throw new \Mpdf\MpdfException(
sprintf('Data has already been sent to output (%s at line %s), unable to output PDF file', $filename, $line)
);
}
Like mentioned all I am getting is a blank page, if I output to an iframe it works ok.
Works fine on 127.0.0.1
Any help much appreciated and thanks in advance for any help
Update:
Sorry forgot to mention or show the code calling the pdf.
I have already tried ob_clean() and still no go
require_once 'pdf/vendor/autoload.php';
if(ob_get_length() > 0) {
ob_clean();
}
$mpdf = new \Mpdf\Mpdf();
$html ='<html>
<body>
<h2 style="font-size: 120px; text-align:center;">SOLD</h2>
<h2 style="font-size: 50px; text-transform: uppercase; text-align:center;">'. $row->widget_model .'</h2>
<h2 style="font-size: 50px; text-transform: uppercase; text-align:center;">'. $row->widget_serial .'</h2><br>
<h2 style="font-size: 30px; text-transform: uppercase; text-align:center;">Delivery Date: '. (new DateTime($_POST['expdelivery']))->format('d-m-Y') .'</h2>
<br>
<h2 style="font-size: 20px; text-align:center;">Contact: '. $_POST['name'] .'</h2>
</body>
</html>';
$mpdf->WriteHTML($html);
$mpdf->Output('sold.pdf','I');
ob_end_flush();
}
EDIT 2:-
Looking at the network Tab it is just showing all the js calls and favicon.ico
It also shows this page updatewidget.php?id=2178
<?php
$page_title = "Widget Tracker - Amend Widget";
$page = '';
include "includes/header.php";
include "includes/sidebar.php";
$id = isset($_GET['id']) ? $_GET['id'] : NULL;
$sth = $db->prepare("SELECT * FROM `widgettracker` WHERE `id` = :id");
$sth->bindParam(':id', $id, PDO::PARAM_INT);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
$row = $sth->fetch();
?>
<section class="content">
<div class="container-fluid">
<?php
if($row->widgetstatus == "Sold")
{include "sold.php";}
else
{include "widgetdetails.php";}
?>
</div>
</section>
<?php
include "includes/footer.php";
include "includes/customjs.php";
?>
And the page that has the Mpdf on is "widgetdetails.php" I need to insert a Sold date and update and generate the pdf. Then the error
You might have a blank line or newline after the closing ?> in your header file. Try removing the closing ?> from your php files that are not actually outputting anything.
You will want to check the network tab in your developer console. You should be able to see the raw data returned by the server, which should show you whatever data it is sending before it reaches the mpdf code.
and sry in advance because i'm new here and i'm completly new in php/ajax coding.
I use a free script (Ajax vote up/down) from this site
I have a simple php page for my shoutcast server to show the song played
<?php
require_once "inc.php";
$array = array(); // Let's store our shoutcast variables into an array.
$array['host'] = "xxx.xxx.xx.xxx"; // Your Shoutcast Host
$array['port'] = "xxxx"; // Your Shoutcast Port
$array['extra'] = "/admin.cgi?sid=1&mode=viewxml&page=1"; // The bit that follows in the url to access the xml of the stats
$array['user'] = "xxxxx"; // Admin username (Default is usually "admin")
$array['password'] = "xxxxxxx"; // Admin Password
$radioStats = new radioStats( $array['host'], $array['port'], $array['extra'], $array['user'], $array['password']);
$returnStats = $radioStats->returnStats();
$song = $returnStats['currentSong'];
?>
<div align="center">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<link href="votingfiles/voting.css" rel="stylesheet" type="text/css" />
<script src="votingfiles/voting.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
setInterval(function(){cache_clear()},54000);
});
function cache_clear()
{
window.location.reload(true);
}
</script>
<div id="radio_stats">
<?php
if( $returnStats['serverStatus'] != 0 ) {
?>
<?php
if( $returnStats['currentSong'] != "" ) {
echo $returnStats['currentSong'];
} else {
echo "Undefined";
}
?></div>
<br /><br />
<div class="vot_updown1" id="vt_$song"></div>
<?php
}
else {
?>
This radio server appears to be offline.
<?php
}
?>
My problem is :
All request Php/ajax/mysql works but actually when i make a vote, it's registered in the db like :
vt_$song 1 0
How can i do to get the real name of the song like the original php request do :
echo $returnStats['currentSong']; or echo $song;
To register in the db like :
vt_Kidd Guti-Step Everything 1 0 (or any other song played)
Example : [HERE]
Thanks in advance for any help.
In this line the $song is not parsed as PHP so the literal text $song is showing:
<div class="vot_updown1" id="vt_$song"></div>
Try:
<div class="vot_updown1" id="vt_<?php echo $song; ?>"></div>
I am trying to install sitecake, I followed all the instructions by adding <?php include "sitecake/server/sitecake_entry.php"; ?> on the top of the page and classes to the divs that I want to be edited.
The problem is, when I add <?php include "sitecake/server/sitecake_entry.php"; ?> my PHP stops working, why is that? what I am doing wrong?
For example, here is one of my PHP scripts that is added to the pages using PHP include:
<!--add class .active to current page-->
<?php
$directoryURL = $_SERVER['REQUEST_URI'];
$path = parse_url($directoryURL, PHP_URL_PATH);
$components = explode('/', $path);
$currentPage = preg_replace("/\\.[^.\\s]{3,4}$/", "", end($components));
if ($currentPage == "") {
$currentPage = "index";
}
function href($url) {
global $currentPage;
$path = explode('/', $url);
$page = preg_replace("/\\.[^.\\s]{3,4}$/", "", end($path));
echo 'href="' . $url . '" ';
if ($page == $currentPage) {
echo 'class="active"';
}
}
?>
Here is the error I get when I use error_reporting(E_ALL):
Fatal error: Uncaught exception 'Zend_Session_Exception'
with message 'Session must be started before any output has been sent to the browser; output started in /home/approach/public_html/index.php/2'
in /home/approach/public_html/sitecake/server/library/Zend/Session.php:454
Stack trace:
#0 /home/approach/public_html/sitecake/server/library/Zend/Session/Namespace.php(143): Zend_Session::start(true)
#1 /home/approach/public_html/sitecake/server/application/services/impl/onesite/Bootstrap.php(21): Zend_Session_Namespace->__construct('Default', false)
#2 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initSession()
#3 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('session')
#4 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract->_bootstra in /home/approach/public_html/sitecake/server/library/Zend/Session.php on line 454
Your error message is this:
Session must be started before any output has been sent to the browser; output started in /home/approach/public_html/index.php/2
And the error occurred at:
/home/approach/public_html/sitecake/server/library/Zend/Session.php:454
The full explanation of the meaning of this message is already explained in detail at another answer, I highly recommend that you read this answer to get a better example of what's going on.
For your specific case, it would seem that you're including your sitecake_entry.php script at the top of the page, or, at least somewhere before you initialize Zend. What you want to do, is this (from the SiteCake examples page):
<?php include "sitecake/server/sitecake_entry.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I don't know the details of Zend, or your application in particular, the thing you probably want to do is find your HTML template, you could search your projects's directory for <!DOCTYPE, and add the line above that, as per the example, instead of adding it to your index.php.
A friend of mine wrote this script, displaying the 20 most recent instagram images, and I was wondering, how can I change the amount of images it grabs to maybe, 6?
<?PHP
$token = 'token';
$username = 'username';
$userInfo = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?q='.$username.'&access_token='.$token));
if($userInfo->meta->code==200){
$photoData = json_decode(file_get_contents('https://api.instagram.com/v1/users/'.$userInfo->data[0]->id.'/media/recent/?access_token='.$token));
if($photoData->meta->code==200){ ?>
<?PHP foreach($photoData->data as $img){
echo '<img src="'.$img->images->thumbnail->url.'">';
} ?>
<?PHP } // If
} // If
?>
Now, the script is functional now because I've been working on it all day, but I'm not sure how to change how many it sends out.
Also, would any of you know how to style this? I already have the CSS done for it, but whenever I try it, it doesn't work correctly.
And, would you know how to get the description of the photo using the API?
Thank you in advance :-)
You need to use Instagram's count= url parameter when requesting data from their endpoints.
For example: https://api.instagram.com/v1/users/search?count=6
Or in your code:
<?PHP
$token = 'token';
$username = 'username';
$userInfo = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?count=6&q='.$username.'&access_token='.$token));
if($userInfo->meta->code==200){
$photoData = json_decode(file_get_contents('https://api.instagram.com/v1/users/'.$userInfo->data[0]->id.'/media/recent/?count=6&access_token='.$token));
if($photoData->meta->code==200){ ?>
<?PHP foreach($photoData->data as $img){
echo '<img src="'.$img->images->thumbnail->url.'">';
} ?>
<?PHP } // If
} // If
?>
Pseudo example for styling. You'll need to figure out the css styles for that, but shouldn't be to difficult.
<div class='myBorder'>
<img url=$img->link />
<div class='myCaption'>$img->caption->text</div>
</div>
To get the description
if (isset($img->caption)) {
if (get_magic_quotes_gpc()) {
$title = stripslashes($img->caption->text);
} else {
$title = $img->caption->text;
}
}
i am using a twitter script to post messages to the twitter wall from a html form
see here:
<form name="csp_post" action="/test.php" method="post" >
<textarea name="text" id="text" rows="3" cols="64" ></textarea>
<input type="hidden" name="action" value="post">
<?php session_start();
include 'twitter-oauth/lib/EpiCurl.php';
include 'twitter-oauth/lib/EpiOAuth.php';
include 'twitter-oauth/lib/EpiTwitter.php';
include 'twitter-oauth/lib/secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
if(isset($_SESSION['oauth_token'])){
$oauth_token = $_SESSION['oauth_token'];
}
else {
$oauth_token = $_GET['oauth_token'];
$_SESSION['oauth_token']=$_GET['oauth_token'];
}
$oauth_token = $_GET['oauth_token'];
if($oauth_token == '')
{
$url = $twitterObj->getAuthorizationUrl();
echo "<div style='width:auto;margin-top:10px;margin-left:10px;margin-right:auto'>";
echo "<a href='$url'>Sign In with Twitter to post Comments</a>";
echo "</div>";
}
else
{
echo "<div style='width:auto;margin-top:10px;margin-left:10px;margin-right:auto'>";
echo "Your comments are now being posted on Twitter";
echo "</div>";
$twitterObj->setToken($_GET['oauth_token']);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
$_SESSION['ot'] = $token->oauth_token;
$_SESSION['ots'] = $token->oauth_token_secret;
$twitterInfo= $twitterObj->get_accountVerify_credentials();
$twitterInfo->response;
$username = $twitterInfo->screen_name;
$profilepic = $twitterInfo->profile_image_url;
}
if(isset($_POST['cssp']))
{
$msg = $_REQUEST['text'];
$twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
$update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
$temp = $update_status->response;
echo "<div align='center'>Updated your Timeline Successfully .</div>";
}
?>
<input type='image' src='../images/123.gif' rel='submit' border='0' value='Tweet' name='cssp' id='cssp' alt='Share'/>
</form>
so the twitter will grab whatever i post into the text area and post it onto the wall.
i would like to do the same with facebook. I know there are applications that can do the same thing, but the ones i found uses a different textarea, and i want to use the one i have already.
any ideas?
Thanks
You can use the Facebook Graph API for this (documentation: http://developers.facebook.com/docs/reference/api/), specifically the following function:
http://developers.facebook.com/docs/reference/api/post/
Read the bottom of the page, the block named Publishing, this should do what you want.
To authenticate using the account to your choice, you will have to use OAuth (http://developers.facebook.com/docs/authentication/); this is rather complex so I would highly recommend using a library for this, preferably Facebooks own PHP Library: https://github.com/facebook/php-sdk/