Skip to content

Commit

Permalink
solved request problem
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSterenson committed May 19, 2016
1 parent 92a75d9 commit 4e69757
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/nbproject/private/
10 changes: 8 additions & 2 deletions APi/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class betaFaceApi
var $api_url;
var $poll_interval;
var $image_Attributes;
var $log_level = -1;
var $log_level = 1;
var $countConnect = 0;

function _betaFaceApi($api_key,$api_secret,$api_url,$poll_interval,$PhotoId)
{
Expand Down Expand Up @@ -88,8 +89,11 @@ function get_Image_attributes($url)
}
while(!$result['ready'])
{
if($this->countConnect == 30)
return -1;
sleep($this->poll_interval);
$result = $this->api_call('GetImageInfo', array('image_uid' => $img_uid));
$this->countConnect++;
}

if($result['face_uid'])
Expand Down Expand Up @@ -177,14 +181,16 @@ function api_call($endpoint,$params)

//open curl connection
$ch = curl_init();
//$timeout = 30;

//set the url, POST vars, POST data and headers
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$request_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

//curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);

$result = curl_exec($ch);

if(!$result)
Expand Down
7 changes: 7 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_56
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
9 changes: 9 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>profileanalysis</name>
</data>
</configuration>
</project>
1 change: 1 addition & 0 deletions php/DbWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private function update_cell($tableName, $keyCol, $keyValue, $coloumnName, $valu

#region Methods (public)
public function execute($sql_string) {
echo "execute: ". $sql_string. "<br>";
return $this->connection->query($sql_string);
}

Expand Down
13 changes: 4 additions & 9 deletions php/Facebook_Photoattributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
include 'DbWrapper.php';
include("../APi/api.php");


<<<<<<< HEAD
$startAttId = 101;
$endAttId = 201;
=======
$startAttId = 31;
$endAttId = 100;
>>>>>>> 34d0e362eb7266a7329c2915880df9a4e01ca061
$startAttId = 75;
$endAttId = 90;


function get_tiny_url($url) {
Expand Down Expand Up @@ -60,6 +54,7 @@ function insert_attributes($id) {
// face found
$setIsValidPhoto = 1;
$dbWrapper->insert($api->image_Attributes);

}
if($face == false){
echo "API call to upload image failed! : $id";
Expand All @@ -79,7 +74,7 @@ function insert_att_all_photo() {
for ($i = $startAttId; $i <= $endAttId; $i++) {
echo "id : $i <br>";
insert_attributes($i);
if ($id % 10 == 0){
if (($id % 10) == 0){
echo "sleeping for 5 sec";
sleep(5);
}
Expand Down
3 changes: 3 additions & 0 deletions php/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ protected function insert_attributes($id) {
// face found
$setIsValidPhoto = 1;
$dbWrapper->insert($api->image_Attributes);
$updateQuery = "UPDATE `Photos` SET `IsValidPhoto` = $setIsValidPhoto WHERE `Id` = $id";
$result = $dbWrapper->execute($updateQuery);

return 1;
}
if($face == false){
Expand Down

0 comments on commit 4e69757

Please sign in to comment.