facebook Graph api fetch list of all friends - facebook-graph-api-v2.0

I am working in a project where i have to integrate face-book graph-api. Everything is going well
but i stuck in a problem to fetch my face book friend list using /me/friends/. It return me only
those friends which has log in with my app, but i want my all friend list
$session = new FacebookSession( $session->getToken());
$friends= (new FacebookRequest( $session, 'GET', '/me/friends' ))->execute()->getGraphObject()
->asArray();
echo '<pre>' . print_r( $friends, 1 ) . '</pre>';
It return
[data] => Array
(
[0] => stdClass Object
(
[name] => Nitin Chamola
[id] => 792718557454395
)
[1] => stdClass Object
(
[name] => Ajay Aggarwal
[id] => 765446336856080
)
[2] => stdClass Object
(
[name] => Manjit Singh Jassal
[id] => 1538019986415496
)
[3] => stdClass Object
(
[name] => Sapna Thakur
[id] => 1518184435101741
)
)
[paging] => stdClass Object
(
[next] => https://graph.facebook.com/v2.2/1587893521432407/friends?access_token=CAAGPXznoOFkBAOCKznoJ4AwZBi9DhlNQYuvgn1qT1Qz3x0JE5mUT5JXOnEnhPtpcriJjoRB5K2yNW3B2L0PtJEcgy8MK3NbZB2oHeBPEeayudFSSxDDOTYUc4J3Q9zDkBqsIGcDcHyzECBtHqOM2HKRUwdOmsSRAJQ41lVWj0T1O2bH1P4ZC2Or2Gv0FuVTL7Wp2xudgGsDHyjwLvGT&limit=25&offset=25&__after_id=enc_AexVs_nuUmTOuF4B5iplPfzsuPs6vtQGx7TV_pH-cINIX2nUIvn3vdmWzNINrKx-vqDnpavxrIA_kr3aqSr6lw4k
)
[summary] => stdClass Object
(
[total_count] => 242
)

After Graph API 2 and above you can no longer do this. You can only fetch the list of those friends who use your app i,e who have given permission to your app. This has been done by fb for security reasons.

Related

how can i get userchat id in telegram bot using phone number in php

I need to get user id of a specific phonenumber group and for this i user SendContact Telegram bot api method to share my phone numbers with my own chat id , but when i get telegram server response i don't get any chat id however my phone numbers are registered in telegram but telegram server send no response that include chat id of that phone number , just server return the phonenumber that i shared with the name that i choose for sharing that.
please help me thanks.
you can see telegram response to my request in next lines :
stdClass Object
(
[ok] => 1
[result] => stdClass Object
(
[message_id] => 98
[from] => stdClass Object
(
[id] => 12334567
[is_bot] => 1
[first_name] => botname
[username] => botusername
)
[chat] => stdClass Object
(
[id] => myid
[first_name] => myfirstname
[username] => myusername
[type] => private
)
[date] => 1532279079
[contact] => stdClass Object
(
[phone_number] => 9891911111111
[first_name] => qqqq
)
)
)
You can have a look at SendContact method
For response you will get Message object, that contains field from and field contact.
Both of them contains user_id/chat_id field.
In your stdClass Object chat_id is in result.from.id

Google Cloud Vision OCR API returning incorrect values for bounding box/vertices

I'm using the "TEXT_DETECTION" option from the Google Cloud Vision API to OCR some images.
The bounding box around individual characters is sometimes accurate and sometimes not, often within the same image.
Is this a normal side-effect of a probabilistic nature of the vision algorithm, a bug in the Vision API, or of course an issue with how I'm interpreting the response?
Here's the portion of the response specific to the letter "a" from which I'm extracting the bounding box.
stdClass Object
(
[property] => stdClass Object
(
[detectedLanguages] => Array
(
[0] => stdClass Object
(
[languageCode] => en
)
)
)
[boundingBox] => stdClass Object
(
[vertices] => Array
(
[0] => stdClass Object
(
[x] => 419
[y] => 304
)
[1] => stdClass Object
(
[x] => 479
[y] => 304
)
[2] => stdClass Object
(
[x] => 479
[y] => 397
)
[3] => stdClass Object
(
[x] => 419
[y] => 397
)
)
)
[text] => a
)

Telegram photo format with getUserPhotos

I use getUserPhotos to get profile photos. What is the main standard source that I should use for html src attribute? (I searched even in telegram's docs, but didn't get the solution.)
A part of my result (type is photos.Photos):
Array
(
[_] => photos.photosSlice
[count] => 14
[photos] => Array
(
[0] => Array
(
[_] => photo
[has_stickers] =>
[id] => 195744071274310414
[access_hash] => -5116812755800708610
[date] => 1472714208
[sizes] => Array
(
[0] => Array
(
[_] => photoSize
[type] => a
[location] => Array
(
[_] => fileLocation
[dc_id] => 4
[volume_id] => 425426808
[local_id] => 100105
[secret] => -7781982930425156181
)
[w] => 160
[h] => 160
[size] => 11694
)
...
What you need to do is use the following method to download your file or picture:
upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File;
Where InputFileLocation is defined below, and may be obtained from PhotoSize.location in your question above:
inputFileLocation#14637196 volume_id:long local_id:int secret:long = InputFileLocation;
more details on file download here: https://core.telegram.org/api/files#downloading-files

how to get result for api connecting to whoapi?

As according to the mention documentation at whoapi.com i have gone through as mention according to instruction and tried implementing the api but the variable doesn't pass from one page to other.For example i have one page which have input type and submit button then when i click submit button it should redirect to who api url and display result
http://api.whoapi.com/?domain=whoapi.com&apikey=demokey&r=blacklist
whoapi.com = name of url,demokey = key assigned by who api & blacklist = name of service of who api
guide me through the connecting protocol.
Not sure I understand the question. Using the API should be straight simple as any REST request is.
PHP example:
$domain = "whoapi.com";
$r = "blacklist";
$apikey = "demokey";
$request = "http://api.whoapi.com/?domain=$domain&r=$r&apikey=$apikey";
$output = json_decode(file_get_contents($request), true);
Resulting array with print_r($output) looks like this:
[status] => 0
[ip] => 88.198.98.181
[blacklisted] => 0
[blacklists] => Array
(
[0] => Array
(
[tracker] => invaluement.com
[blacklisted] => 0
)
[1] => Array
(
[tracker] => surbl.org
[blacklisted] => 0
)
[2] => Array
(
[tracker] => barracudacentral.org
[blacklisted] => 0
)
[3] => Array
(
[tracker] => sorbs.net
[blacklisted] => 0
)
[4] => Array
(
[tracker] => spamhaus.org
[blacklisted] => 0
)
)
Hope this helps.

PDO::FETCH_ASSOC Does not return the correct table columns

I'm new to PHP and I am currently developing a small web application. Below is the test code for the DB query using PDO:
try
{
$dsn = "mysql:host=localhost;dbname=auction";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
);
$pdo = new PDO($dsn, 'root', 'password', $opt);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $pdo->query("SELECT id,username,password,name,level FROM users");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$test = $stmt->fetchALL();
print_r($test);
The output of the said code is the following:
Array ( [0] => Array ( [id] => 1 [username] => admin [users] => Administrator [auction] => 0 )
[1] => Array ( [id] => 2 [username] => jodel [users] => Jodel Ross [auction] => 1 ) )
I am confused because, from my point of view, the above code should have given an associative array whose index are the columns of the returned result set, i.e. id, username,password,name,level. But it is not so.
Moreover, If I used PDO::FETCH_NUM, the correct number of fields and corresponding data are returned correctly as show below:
Array ( [0] => Array ( [0] => 1
[1] => admin
[2] => 21232f297a57a5a743894a0e4a801fc3
[3] => Administrator
[4] => 0 )
[1] => Array ( [0] => 2
[1] => jodel_ross
[2] => 2cdaeb5df4cf941d9c5650591cba1fdc
[3] => Jodel Ross, Jr.
[4] => 1 ) )
Please help, I need to understand why and I have search the web for answers and have not found any.
Thanks.
Development environment:
Windows 7 x64
PHP 5.3.6
Mysql 5.5
Apache 2.0.64
Zend Framework 1.11
There is still an open error with Zend Framework 1.x, PHP 5.3.x and setFetchMode() and that's the reason why it doesn't work as expected.
see http://framework.zend.com/issues/browse/ZF-10866 and http://framework.zend.com/issues/browse/ZF-3470
Please vote for closing this error or submit a patch.