Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* 2015 (c) dwi-siswant0.blogspot.com */
- // recommend for trig; 5 minutes
- $token = array(
- "ig" => "...", // access token Instagram Anda
- "fb" => "..." // access token Facebook Anda
- );
- $sopo = array(
- // kumpulan username Instagram target yang ingin ditransfer fotonya ke Facebook (secara acak)
- "8crap",
- "8dict",
- "9gag",
- "9gaggeeky",
- "graffiti_legendz",
- "memecomicindonesia",
- "parodi.seru"
- );
- function hajar($yuerel, $dataAing=null) {
- $cuih = curl_init();
- curl_setopt($cuih, CURLOPT_URL, $yuerel);
- if($dataAing != null){
- curl_setopt($cuih, CURLOPT_POST, true);
- curl_setopt($cuih, CURLOPT_POSTFIELDS, $dataAing);
- }
- curl_setopt($cuih, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($cuih, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($cuih, CURLOPT_SSL_VERIFYPEER, false);
- $eks = curl_exec($cuih);
- curl_close($cuih);
- return $eks;
- }
- function search($user) {
- global $token;
- echo "=> Getting account : ";
- $cari = json_decode(hajar("https://api.instagram.com/v1/users/search?q=" . $user . "&access_token=" . $token['ig']), true);
- if ($cari['meta']['code'] == 200 && (isset($cari['data'][0]['username']))) {
- echo "OK!";
- echo "\nUname: " . $cari['data'][0]['username'];
- echo "\nUID: " . $cari['data'][0]['id'] . "\n\n";
- return $cari;
- } else {
- echo "ERROR!\n";
- echo "Failed when getting Instagram account you want to transfer, please check the list of accounts.";
- exit;
- }
- }
- function fetch() {
- global $token, $sopo;
- $cari = search($sopo[array_rand($sopo)]);
- echo "=> Fetch a photo : ";
- $fetch = json_decode(hajar("https://api.instagram.com/v1/users/" . $cari['data'][0]['id'] . "/media/recent?count=1&access_token=" . $token['ig']), true);
- if ($fetch['data'][0]['type'] == "image" && $cari['meta']['code'] == 200) {
- echo "OK!\n";
- echo "Link: " . $fetch['data'][0]['link'];
- echo "\nCaption: " . $fetch['data'][0]['caption']['text'];
- echo "\nID: " . $fetch['data'][0]['id'] . "\n\n";
- return $fetch;
- } elseif (isset($fetch['meta']['error_type'])) {
- echo "Something error.\n";
- echo $fetch['meta']['error_message'];
- exit;
- }
- }
- $ambil = fetch();
- echo "=> Post to Facebook : ";
- $kirim = json_decode(hajar("https://graph.facebook.com/me/photos", array(
- "message" => $ambil['data'][0]['caption']['text'],
- "url" => $ambil['data'][0]['images']['standard_resolution']['url'],
- "access_token" => $token['fb'])
- ), true);
- if (isset($kirim['post_id'])) {
- echo "OK!";
- echo "\nPID: " . $kirim['post_id'];
- } elseif (isset($kirim['error'])) {
- echo "ERROR!\n";
- echo $kirim['error']['message'];
- } else {
- echo "ERROR!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement