没有任何东西被贴到墙上,执行结束后试试$ result = $ facebook-> api('/ me/feed /','post',$ attachment); 声明,任何想法都破了.
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Get the user profile data you have permission to view
$user_profile = $facebook->api('/me');
$uid = $facebook->getUser();
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'email,publish_stream,status_update,user_birthday,user_location,user_work_history'));
$attachment = array
(
'access_token'=>$facebook->getAccessToken(),
'message' => 'I had a question: should I write a PHP facebook app …Run Code Online (Sandbox Code Playgroud) 获取用户朋友的所有个人资料图片的最佳方式是什么?我是否必须循环每个Facebook好友或者有更简单的方法吗?
在facebook文档中,它说我们可以指定:
的AppID |揭秘
作为应用程序access_token
但是,当访问https://developers.facebook.com/tools/access_token/时 ,App令牌会有所不同.这是AppID | Randomnumber形式
我们应该使用哪个?PHP SDK使用'秘密'版本 - 我们需要调整吗?
我有最艰难的时间搞清楚这一点......我怎样才能获得用户ID?虽然我把问题放在一边听起来有点迟钝,但我无法在任何地方找到它!这是我的以下代码的顶部:
require '../fb_fc/facebook-php-sdk-9147097/src/facebook.php';
$appId = 'APP_ID';
$appSecret = 'APP_SECERT';
$userId = 'USER_ID?????';
$userAccessToken = 'ACCESS_TOKEN';
Run Code Online (Sandbox Code Playgroud)
如何获取用户ID?我通过使用获取访问令牌$GET_['access_token'];,这是URL:http://friendsconnect.org/example.php?access_token = ACCESS_TOKEN_HERE #access_token = ACCESS_TOKEN_HERE&expires_in = 0(这不是一个有效的链接).我怎样才能做到这一点?我也是新手,我愿意接受建议.
我使用以下代码发布到页面的feed连接
$attachment = array('message' => 'xxxxxxxxxxxxxxxxx',
'name' => 'cccccccccccccccc',
'caption' => 'cccccccccccccccc',
'link' => 'http://apps.facebook.com/manydldotnet/',
'description' => "ccccccccccccc",
'picture' => "'cccccccccccccccc'",
'actions' => array(array('name' => 'Download!','link' => 'http://apps.facebook.com/manydldotnet/'))
);
$result = $facebook->api('/121468571287906/feed/','post',$attachment);
Run Code Online (Sandbox Code Playgroud)
所以问题是如何在发布后获得post_id?
我正在编写一个PHP脚本来抓取Facebook API并记录所有用户ID.
例如:
我的第一个想法是从#4开始,每次增加1.该计划的问题在于用户ID存在差距.有时,对于100,000个系列中的每个数字,API都将返回false.这只会浪费我的脚本运行所有这些错误的时间和周期.
有谁知道确定每个有效Facebook用户ID的更好方法?
我使用facebook开发者指南使用facebook api for android.我能够实现facebook api for android的登录.我想实现注销功能.我试过跟随开发者指南,但不知道我必须实现哪个地方.如果你们帮我解决下面的代码,我将不胜感激.
public class FacebookandroidsdkActivity extends Activity {
/** Called when the activity is first created. */
Facebook facebook = new Facebook("252039928190210");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
facebook.authorize(this, new DialogListener() {
@Override
public void onComplete(Bundle values) {}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data); …Run Code Online (Sandbox Code Playgroud) 我正在使用此代码将文本与图像合并,并且工作正常.但是当我在Facebook应用程序中使用此代码时,它不会显示任何输出.有人可以帮我解决问题吗?据我所知,问题在于这一行:
header("Content-Type: image/jpeg");
Run Code Online (Sandbox Code Playgroud)
当我删除它时,它显示一些混乱的输出.
<?php
header("Content-Type: image/jpeg");
$im = ImageCreateFrompng("jump_empty.png");
$black = ImageColorAllocate($im, 255, 255, 255);
$start_x = 10;
$start_y = 20;
Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'ambient.ttf', "hellooo");
Imagejpeg($im, '', 100);
ImageDestroy($im);
?>
Run Code Online (Sandbox Code Playgroud)
这是我用于Facebook应用程序的代码:
<?php
include_once 'facebook.php';
include_once 'config.php';
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => true,
'domain' => '_____'
));
header("Content-Type: image/jpeg");
$session = $facebook->getSession();
if (!$session) {
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'read_stream,publish_stream'
));
echo …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我使用此代码在Facebook上发布照片.
码:
// For Facebook ===================================
Button facebookButton = (Button) saveButtonDialog.findViewById(R.id.facebook);
facebookButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveButtonDialog.dismiss();
saveImageFunction(); // to save the Image
facebook.authorize(TWSBIDrawMainActivity.this, new String[]{ "user_photos,publish_checkins,publish_actions,publish_stream"},new DialogListener() {
@Override
public void onComplete(Bundle values) {
postImageonWall();
Toast.makeText(getApplicationContext(), "Image Posted on Facebook.", Toast.LENGTH_SHORT).show();
}
@Override
public void onFacebookError(FacebookError error) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onCancel() {
}
});
}
});
public void postImageonWall() {
byte[] data = null;
Bitmap bi …Run Code Online (Sandbox Code Playgroud) 好吧,我在我的绳子尽头大声笑.我有以下代码,我知道只要我把它放在我网站的tmp文件夹中就读jpg文件.但是,我仍然遇到恼人的错误:
{"error":{"message":"(#324) Requires upload file","type":"OAuthException"}}
Run Code Online (Sandbox Code Playgroud)
我错过了什么???? 它必须是简单的东西,但如果我能弄清楚的话,我会大胆的.任何帮助是极大的赞赏!!!
这是我的代码:
<html>
<head>
<title>Photo Upload</title>
</head>
<body>
<?php
$app_id = "APP ID HERE";
$app_secret = "APP SECRET HERE";
$post_login_url = "LOGIN IN URL HERE";
$album_name = "My Silly Album";
$album_description = "Blah Blah Photos";
$photo_source = "tmp/Lighthouse.jpg";
$photo_message = 'Here is the lighthouse';
$code = $_REQUEST["code"];
echo "code ==>" . $code . '<br/><br/>';
//Obtain the access_token with publish_stream permission
if(empty($code)){
login($app_id, $post_login_url);
}
else {
$access_token = getAccessToken($app_id, $post_login_url, $app_secret, $code);
echo "access_token …Run Code Online (Sandbox Code Playgroud)