Facebook API images not downloading - facebook

First post here,
i am developing a app to fetch and download facebook images from user's account.
I have a basic code till now as follows..
Need help as to why only the 1 file keeps downloading alone...in the zip i create
it is the only image without the ?oh= concatenation, all others with the oh parameter dont get
downloaded...
<?php
set_time_limit(0);
$url='https://graph.facebook.com/me/photos/uploaded?access_token=CAACEdEose0cBAEGw8R4QOGfN3bfX8qtuZCCy8FX6g5Sil8CKaYlp9x8lZAiNFEGJXhh9MYOWdZAJR1x2M627rc5I3n3AauVe8nJtYBsehjUZAljMLkQMMxP03VVXknZBa81Nk1S23z7SnyTkIlgt2oZC1euoFNCTuGesAap1uQUGZAX7LnILlBwyj3V7IVo9QQCNv66Lv8UcA86wYn9jlJE';
$result = file_get_contents($url);
$a=json_decode($result, true);
$files = array();
echo '<div class="col-lg-12">';
$num= count($a['data']);
echo "<table class='table table-hover table-responsive'>";
for($o=0;$o<$num;$o++)
{
$files_to_zip[$o]=$a['data'][$o]['source'];
if($a['data'][$o]['source']!="")
{
echo "<tr><td><img src='".$a['data'][$o]['source']."' id=".$o." width='200' height='200' /></td></tr>";
array_push($files,$a['data'][$o]['source']);
//echo $files_to_zip[$o]."<br/><br/><br/><br/>";
}
}
echo '</table></div><br/>';
?>

Related

Retrieve users/company information

On connecting to Quickbook within our app we are able to get access token and realmid but on trying to implement Get App Now we couldn't get any information after redirecting to our openid url. What I have tried so far is
define('OAUTH_CONSUMER_KEY', $consumerkey);
define('OAUTH_CONSUMER_SECRET', $consumersecret);
define('OAUTH_URL', 'https://oauth.intuit.com/');
define('APPCENTER_URL', 'https://appcenter.intuit.com/');
define('OAUTH_REQUEST_URL', OAUTH_URL . 'oauth/v1/get_request_token');
define('OAUTH_ACCESS_URL', OAUTH_URL . 'oauth/v1/get_access_token');
define('OAUTH_AUTHORISE_URL', APPCENTER_URL . 'Connect/Begin');
define('OAUTH_CURRENT_USER', APPCENTER_URL . 'api/v1/user/current');
try{
$oauth = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$request_token = $oauth->getRequestToken(OAUTH_CURRENT_USER,CALLBACK_URL);
echo '<pre>';
print_r($_POST);
print_r($_GET);
print_r($_REQUEST);
print_r($_SESSION);
echo $request_token;
print_r($request_token);
echo '</pre>';
} catch(OAuthException $e) {
pr($e);
}
I can't get any valuable information on the above code, I maybe doing it wrong and expecting that there would be realmid and access token once the authorization is done and quickbooks redirect to our openid url. Any information would be appreciated.
Please note I really don't have knowledge about this as this is my first time using quickbooks api and related technologies.
Updated
<?php
require 'openid.php';
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID($_SERVER["HTTP_HOST"]);
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://openid.intuit.com/OpenId/Provider';//'https://www.google.com/accounts/o8/id';
$openid->required = array(
'contact/email',
'namePerson/first',
'namePerson/last'
);
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
When the form above gets submitted it results into No OpenID Server found at https://openid.intuit.com/OpenId/Provider

How do I add extra fields to a YouTube API Browser Upload form?

I have a form to upload video to youtube with zend gdata youtube. the problem is the action url of the form must be the url upload returned by youtube. and then I can not catch others form fields to store them in the database. even the next url returned only 2 vars. status and video id.
Youtube Web services Example.
//Action in your Controller
public function testYoutubeAction(){
Zend_Loader::loadClass("Zend_Gdata_YouTube");
try{`enter code here`
$YouTube = new Zend_Gdata_Youtube();
//Get the specific video
$video = $YouTube->getVideoEntry("NwrL9MV6jSk");
$this->view->video = $video;
}catch(Zend Service_Exception $e)
{ throw $e;
}
}
in test-youtube.phtml
h2>Favorite Video of All Time!</h2><br>
<?php
$title
= $this->video->getVideoTitle();
$uri
= $this->video->getVideoWatchPageUrl();
$description = $this->video->getVideoDescription();
$thumbnails = $this->video->getVideoThumbnails();
$duration = $this->video->getVideoDuration();
$thumbnail = $thumbnails[1]['url'];
?>
<table>
<tr><td><img src='<?php echo $thumbnail ?>' height=50 width=50></td>
<td valign="top"><a href='<?php echo $uri ?>'><?php echo $title ?></a><br>
Duration <?php echo $duration ?> sec</td>
</tr>
</table>

Facebook login loads landing page inside popup window

After signing up to my site as a new member, redirect page is loaded inside the FB login popup window. And I can not figure it out.
if (!session_id()) session_start();
$_SESSION['userid'] = $user_id;
$_SESSION['FirstName'] = $fname;
$_SESSION['loginFb'] = $logoutUrl;
header("Location: sign-up/welcome");
echo "<script>
window.close();
window.opener.location.reload();
</script>";
exit();
How should the code has to be corrected in order to get the redirection page in the main browser?
header("Location: sign-up/welcome");
In general PHP executed before HTML, CSS and JS does that's why, remove it and it should work
if (!session_id()) session_start();
$_SESSION['userid'] = $user_id;
$_SESSION['FirstName'] = $fname;
$_SESSION['loginFb'] = $logoutUrl;
echo "<script>
window.close();
window.opener.location.reload();
</script>";
exit();

php form processing issue when processing script returns to the calling script

Problem:
form processing script throws error when returning back to the calling script which is the user entry form.
error message
Notice: A session had already been started - ignoring session_start() in /inc/utilities.inc.php on line 3 Fatal error: Cannot redeclare class Connection in /inc/dbconn.php on line 5
The code is a bit too large to copy past all of it so im just going to focus on the problem area.
newproject.php calls -> savenewproject.php. if savenewproject.php finds error it returns back to newproject.php to display error message.
//newproject.php - parts of the code that i believe is the problem area.
<?php
include('../inc/utilities.inc.php');
include('header.php');
if (!empty($errorString))
{ echo '<div class="error">' . $errorString . '</div>'; }
if (!empty($successString))
{ $emailaddress = '';
$budget = '';
$projecttitle ='';
$projectdescription = '';
echo '<div id="divfadeout" class="success">' . $successString . '</div>';
}
?>
<form name ='newProject' action="../inc/savenewproject.php" enctype="multipart/form-data" method="POST">
the rest are form fields
</form>
// include('../inc/utilities.inc.php'); - appears in both script
<?php
session_start();
$user = (isset($_SESSION['user'])) ? $_SESSION['user']: null;
include("../inc/dbconn.php");
?>
// savenewproject.php - copy/pasting what i believed to be the problem area.
if(count($fieldErrors) > 0)
{ $errorString = '<p>There was an error processing the form.</p>';
$errorString . 'ul>';
foreach($fieldErrors as $errorVal)
{ $errorString .= "<li>$errorVal</li>"; }
$errorString .= '</ul>';
include ('../layout/newproject.php');
}
else
{
looks like i answered my own question..
instead of include i used request once and it seems to have fixed the probelm..

Retrieve facebook posts more than its default limit

Is there a method to retrieve more posts from facebook? I am developing a site which needs to retrieve at least 200 posts from facebook. Right now I am getting 24 posts only. Is it possible to get 200 posts?
$user_posts = json_decode(#file_get_contents(
'https://graph.facebook.com/me/posts?access_token='.$access_token));
$user_posts = (array)$user_posts;
$user_posts = $user_posts['data'];
echo "<h1>Posts</h1>";
foreach($user_posts as $user_post){
$user_post = (array)$user_post;
echo "<table border='8' width='500'>";
if(($user_post['picture'])||($user_post['message'])){
echo "<tr>";
echo '<td height="4"></td>';
echo "<td>";
if($user_post['message']){
echo "<tr><td>Message : ".$user_post['message']."</td></tr>";
}
}
}
Thanks.
I found the answer for this one.
Just add a limit field to the url.
$user_posts = json_decode(#file_get_contents(
'https://graph.facebook.com/me/posts?access_token='.$access_token.'&limit=200'));