Jump to content

ILYAS415

Members
  • Posts

    292
  • Joined

  • Last visited

Posts posted by ILYAS415

  1. I'm no expert in PHP, so forgive if this is a stupid question, but why is all your html in a function? 

    I mean, you could try taking all the html out of the function. Perhaps the code below will help me explain better:

    // Maakt nieuw/edit record formulier
            function renderForm($bedrijfsnaam ='', $factuurbedrag ='', $vervaldatum ='', $voldaan ='', $opmerkingen ='', $id ='')
            { ?>
    
    All of your HTML is here
    
    <? }
    
    
    //your input is processed down here but it seems you dont need the function renderForm
    
  2. Fortunately, after HOURS of searching, I found another script that worked for me which allows me to publish to a page as the pages admin.

     

    It is as below, in case anybody else wants to use it:

    // Get these from http://developers.facebook.com
    $appid = 'appID here';
    $secret  = 'secret here';
    $page_id = '520883404668278';
    
    
    $message = "Message you want to post here";
    
    	require_once 'src/facebook.php';
            // PATH TO YOUR Facebook SDK php file
    
    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
      'appId'  => $appid,
      'secret' => $secret,
    ));
    
    // Get User ID
    $user = $facebook->getUser();
    echo $user;
    
    if ($user) {
      try {
        $page_info = $facebook->api("/$page_id?fields=access_token");
    	
        if( !empty($page_info['access_token']) ) {
            $args = array(
                'access_token'  => $page_info['access_token'],
                'message'       => $message 
            );
            $post_id = $facebook->api("/$page_id/feed","post",$args);
    		
        } else {
            $permissions = $facebook->api("/me/permissions");
            if( !array_key_exists('publish_stream', $permissions['data'][0]) ||
               !array_key_exists('manage_pages', $permissions['data'][0])) {
                    // We don't have one of the permissions
                    // Alert the admin or ask for the permission!
                    header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages")) );
            }
        }
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }
    
    // Login or logout url will be needed depending on current user state.
    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl();
    } else {
      $loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,publish_stream'));
    }
    
    

    The only thing is that I am still unsure why my initial code did not work. 

  3. Video games... web design.... does it get any better?!?!?

     

    Welcome :) I got into PHP exactly like you (playing text-based mafia games)!

    There is so much support on this forum so those new to PHP.

     

    Good luck!

  4. Hi. I am currently working on a script designed so that the admin of a website can post onto a Facebook wall for his companies Page. This is my first ever time working with Facebooks SDK API and I'm finding loads of outdated tutorials and scripts out there so I'm really stumped.

     

    This is what I've written so far:

    // Get these from http://developers.facebook.com
    $api_key = '**************';
    $secret  = '*********************************';
    $token = '**************|*************************';
    $pageid = '*******************';
    
    // ^^ ABOVE IS THE API, SECRET TOKEN INFO ETC WHICH IVE OMMITTED
    
    include_once '****/*****/src/facebook.php'; //ommitted link to fb sdk
    
    	$facebook = new Facebook(array(
                 'appId' => $api_key,
                 'secret' => $secret,
                 'cookie' => true
             ));
    		 	 
    	$user_id = $facebook->getUser(); //works
    	//END OF FACEBOOK REQUIRED INFORMATION
    	
    	echo "USER ID: ".$user_id."<br />"; //it succesfully gets user id
    
    	if($user_id) {
    
          // We have a user ID, so probably a logged in user.
          // If not, we'll get an exception, which we handle below.
          try {
    		  
    		$facebook->setAccessToken(qa_opt('facebook_page_access_code'));
    		// Try to extend token
            $access_token = $facebook->getExtendedAccessToken();  
    		  
            $attachment = array(
                'access_token' => $token,
                'message' => 'message here', 
                'link'    => 'http://domain.com/index.php',
                'picture' => 'http://domain.com/images/image.png',
                'name'    => 'Name',
                'description'=> 'Latest news for domain.com.'
        	);
    		
    	
          ///       THE BELOW LINE IS CAUSING SOME SORT OF ERROR
          $res = $facebook->api('/'.$pageid.'/feed','POST',$attachment);
    
    	echo "Post done!";
    		
    		
          } catch(FacebookApiException $e) {
            // If the user is logged out, you can have a 
            // user ID even though the access token is invalid.
            // In this case, we'll get an exception, so we'll
            // just ask the user to login again here.
            $login_url = $facebook->getLoginUrl( array(
                           'scope' => 'publish_stream'
                           )); 
            echo 'Please <a href="' . $login_url . '">login.</a>';
            error_log($e->getType());
            error_log($e->getMessage());
          }
    

    I didn't include the entire script because I believe the problem mainly concerns the following piece of code from the above:

    $res = $facebook->api('/'.$pageid.'/feed','POST',$attachment);
    

    The thing is, when the above line is commented (and thus not executed by the script), the script runs without errror and displays "post done!"

    If I change the $res variable to:

    $res = $facebook->api('me/feed', 'post', array(
                 'message' => 'Hello World!'
             ));
    
    

    The script will post but it will post to my wall. However, I need it to post to the Facebook Page (i.e. a company page) and I know I need to use something like the $res variable I first cited from my script.

     

    So the jist of my question is: what am I missing/doing wrong that won't let me post to a facebook page as the pages admin?

     

    Thanks guys.

  5. Found out that my directory permissions were a bit weird. The directory was not executable or readable apparently. This is the function that the script uses to create the directory:

    mkdir("$desired_dir", 0700);
    

    My question is simply, how can I make it so that when the directory is created, the permissions are already there so that other pages on my host can view the directory and its files?

  6. Hi guys,

     

    Basically I have a PHP script which uploads images and makes an SQL query. The script works perfectly, and the images are uploaded into a new directory created by the script. However, when I try to view the file directly though the browser, I get a 404 Page not found error. This is the same issue as when I try to link to the image with an img src tag.

     

    I know that the image exists where it does because I can see the file and download it from my file manager. I have attached screenshots showing my predicament :)

     

    Thanks.

     

    post-40012-0-31185100-1379714838_thumb.png

     

     

    post-40012-0-36703400-1379714845_thumb.png

  7. Hi guys. I'm having quite a problem with flash interaction. Heres my flash file:-

     

    http://www.ilyas-shezad.com/worldmap.html

     

    The problem with the file is that the script aborts for some reason. Ive come to notice that it aborts because of my LoadVars line:-

     

    loadVariables('2php.php', 0, "GET");

     

    When I get rid of this line and replace with with a normal string inside the flash file then the file works without ANY problems.

     

    Here is a download to the file:-

    http://www.ilyas-shezad.com/worldmap.fla

     

    Thank you!

  8. Try...

    <?php
    //Rob Farrell add up options costs
    $BasePrice = $row_rsBaseProduct['BasePrice'];
    $gap = $_GET['gap'];
    
    if ($gap == 0.00) {
    $gap= $BasePrice;
    }
    
    $fin = $_GET['fin'];
    $post = $_GET['post'];
    $Apost = $_GET['Apost'];
    $Finials = $_GET['Finials'];
    $sum_total = $gap+$fin+$post+$Apost+$Finials;
    echo ($sum_total);
    ?>
    

  9. Hey Ive recently been working on a new layout for my website. Its all complete, and while making it I decided to use ajax to make it more user freindly and fast. But fater reading 1 or 2 SEO optimization tutorials, I discovered that Google can only use text links to browse through your site.

     

    Thats quite significant because my links use javascript like...

    <a class="nolink" onClick="GetPage('aboutus.php');">Link</a>
    

     

    Heres the Ajax site:

    http://www.ilyas-shezad.com/index_1.php

     

    Please if you could also leave some feedback as well.

  10. Hi. Im making a game and im tyring to update a players health automatically every 10 seconds.

    Heres what I have come up with...

     

    <script language="javascript" type="text/javascript">
    <!--
    function updateHealth(){
    changeText("health", "<b>H</b>ealth: [<?= $fetch->health ?>/<?= $fetch->maxhealth ?>]");
    }
    setInterval("updateHealth()", 10000); //every 10 seconds
    //-->
    </script>
    

     

    The above code works fine. However if i were to change the players health on the db, it wouldnt change on the page every 10 seconds. It would get the original rows from when the page originally loaded. Help please?

     

    Thanks

  11. function myFunction()
    {
       if($me == "awesome")
       {
          echo "Damn straight.";
       }
       else
       {
          echo "You suck.";
       }
    }

    I hate making my code like that because i read an optimization article that if you put stuff very close together e.g.

    if ($me == "awesome"){ echo "hi"; }else{ echo "you suck"; }
    

    then the server will be able to run the code much faster. or so ive read.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.