Jump to content

digioz

New Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by digioz

  1. Are you using https with these other URL's that work?

     

    For php to be able to make a https request, you need to have OpenSSL installed.

     

    You are absolutely correct, but I don't have OpenSSL installed on my development machine though.

     

     

    Its a commonly overlooked issue, simply using the following line will fix it:

      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

     

    Put that inside your function below:

      curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);

     

    Regards, PaulRyan.

     

    Thank you very much Paul! This worked like a charm. Much appreciated!

     

    Pete

  2. Hello PHP Freaks!

     

    I have the following PHP Curl code which is supposed to fetch the twitter timeline feed for a specific username and parse and display it on a page, but for some reason Curl is unable to fetch data from twitter:

     

    <?php
    function get_data($url)
    {
      $ch = curl_init();
      $timeout = 5;
      curl_setopt($ch,CURLOPT_URL,$url);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
    }
    
    $json = get_data("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=digioz&count=2");
    
    if ($json != false)
    {
        $obj = json_decode($json);
            
        foreach($obj as $var => $value)
        {
            echo "Message number: $var <br/>";    
            echo "Name: " . $obj[$var]->user->name;
            echo "Handle: " . $obj[$var]->user->screen_name . "<br/>";        
            echo "Message: " . $obj[$var]->text;        
            echo "Created" . $obj[$var]->created_at . "<br/>";                    
            echo "URL" . $obj[$var]->user->url . "<br/>";
            echo "Location" . $obj[$var]->user->location . "<br/>";       
            echo "<br/>";
        }
    }
    else
    {
        echo "Could not fetch Twitter Data";
    }
    ?>
    

     

    Anyone have any idea why the data is not being fetched? If I copy and paste the URL into my browser window it returns results just fine, so I know the problem is not with the URL.

     

    Thanks,

    Pete

  3. Thank you delickate. I did try your suggestion, but it looks like because our site is in a shared hosting environment, they do not allow us to increase memory limit or execution time. What's even worse is that they don't allow you to change the maximum upload size either, so we will have to switch to a dedicated web host to be able to do what we need. Here are the setting changes I have in mind to get this to work once we make that switch:

     

    max_execution_time = 600

    max_input_time = 600

    memory_limit = 200M

    post_max_size = 200M

    upload_max_filesize = 200M

     

    Thanks,

    Pete

  4. Hello All,

     

    I have a simple upload form which I am using to upload files to Box.net using PHP Curl. It works fine for small files, but times out for larger files. Anyone have any suggestions for this?

     

    Thanks,

    Pete

     

    Here is the code:

     

    <html>
    <body bgcolor="black">
    <div align="center">
                    <img src="Homepage_02.jpg" border="0" />
                    
                    <br>
                    <br>
                    <font color="#f1ca63"; font face="Arial"; font size="5">Upload</font>
                    <br>
                    <br>
                    
                    <?php
       
                                    if (isset($_POST['upload'])) 
                                    {
                                                    if (!empty($_FILES['new_file_1']['name'])) 
                                                    {
                    $allowedExtensions = array("txt","csv","xml","css","doc", "docx","xls","xlsx","rtf","ppt","pdf","swf","flv","avi","wmv","mov","jpg","jpeg","gif","png");
                    
                    foreach ($_FILES as $file) 
                    {
                        if ($file['tmp_name'] > '') 
                        {
                            if (!in_array(end(explode(".", strtolower($file['name']))),$allowedExtensions)) 
                            {
                                echo $file['name'].' is an invalid file type!<br/>';
                            }
                            else
                            {
                                $temp_name = $_FILES['new_file_1']['name'];
                                $localfile = $_FILES['new_file_1']['tmp_name'];
                                $file = fopen($localfile,'r');
                                
                                $request_url = 'https://upload.box.net/api/1.0/upload/[Token Here]/[Folder ID]';
                                $post_params['check_name_conflict_folder_option'] = urlencode('1');
                                $post_params['new_file_1'] = "@$localfile";
                                $post_params['description'] = urlencode($_POST['description']);
                                $post_params['uploader_email'] = urlencode($_POST['uploader_email']);
                                $post_params['upload'] = urlencode('upload');
    
                                $ch = curl_init();
                                
                                curl_setopt($ch, CURLOPT_URL, $request_url);
                                curl_setopt($ch, CURLOPT_VERBOSE, 1); 
                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
                                curl_setopt($ch, CURLOPT_POST, true);
                                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
                                curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
                                curl_setopt($ch, CURLOPT_TIMEOUT, 300);
                        
                                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                                $result = curl_exec($ch);
                                curl_close($ch);
                                
                                $resultArray = explode(' ',$result);
                                
                                if($resultArray[5] != '')
                                {
                                    $fileID = substr($resultArray[5],4,-1);
                                    $shareName = $temp_name;
                                    $link = 'http://www.box.net/shared/'.$shareName;
                                }
                                
                                $renameurl = addslashes("https://www.box.net/api/1.0/rest?action=rename&api_key=[API KEY]&auth_token=[TOKEN Here]&target=file&target_id=".$fileID."&new_name=".$shareName);
                                
                                $renameResult = file_get_contents($renameurl);
                                                
                                echo '<font color="white">Upload Successful</font>';                        
                                            
                            }
                        }
                    }
                                                    } 
                                                    else 
                                                    {
                                                                    echo '<font color="white">Please select a file</font>';
                                                    }
                                    }
                    ?>
                    
                    <hr width=600 color=grey> 
                    <br>
    
                    <div align="center">
                                    <form action="box_upload_curl.php" enctype="multipart/form-data" method="post"> 
                                                    <input type="hidden" name="check_name_conflict_folder_option" value="1"/> 
                                                                    <table> 
                                                                    <tr> 
                                                                                    <td class="field" style="color: #f1ca63; font-family: Arial; font-size: 14px" width="50%">Choose File to Upload:   </td> 
                                                                                    <td class="input"><input type="file" name="new_file_1" /></td> 
                                                                    </tr> 
                                                                    <tr> 
                                                                                    <td class="field field_top" style="color: #f1ca63; font-family: Arial; font-size: 14px" ><br/> Description (optional):</td> 
                                                                                    <td class="input"><br/><textarea name="description"></textarea></td> 
                                                                    </tr> 
                                                                    <tr> 
                                                                                    <td class="field field_top" style="color:#f1ca63; font-family: Arial; font-size: 14px" >
                                                                                                    <br/> 
                                                                                                    Your e-mail <font color="red">*</font>:
                                                                                    </td> 
                                                                                    <td class="input field_top" style="color: #f1ca63; font-family: Arial; font-size: 14px" >
                                                                                                    <br/>
                                                                                                    <input type="text" name="uploader_email" id="email_input"></input>
                                                                                    </td> 
                                                                    </tr> 
                                                                    <tr> 
                                                                                    <td colspan="2" class="submit" align="center">
                                                                                                    <br />
                                                                                                    <input type="submit" name="upload" value="Upload" />
                                                                                    </td> 
                                                                    </tr> 
                                                                    </table>
                                    </form>
                    <hr width=600 color="grey"> 
    </div>
    
    

×
×
  • 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.