对于PHP–安全地将数据从站点传递到另一个站点感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍php提交数据到另一个php,并为您提供关于android–使用bundle将数据从一个活动传递到另
对于PHP – 安全地将数据从站点传递到另一个站点感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍php提交数据到另一个php,并为您提供关于android – 使用bundle将数据从一个活动传递到另一个活动 – 不在第二个活动中显示、android – 将数据从一个应用程序传递到另一个应用程序、angular – 如何将数据从一个页面传递到另一个页面,以便在Ionic 2中进行导航、angularjs – 将数据从一个指令传递到另一个指令的有用信息。
本文目录一览:- PHP – 安全地将数据从站点传递到另一个站点(php提交数据到另一个php)
- android – 使用bundle将数据从一个活动传递到另一个活动 – 不在第二个活动中显示
- android – 将数据从一个应用程序传递到另一个应用程序
- angular – 如何将数据从一个页面传递到另一个页面,以便在Ionic 2中进行导航
- angularjs – 将数据从一个指令传递到另一个指令
PHP – 安全地将数据从站点传递到另一个站点(php提交数据到另一个php)
我有一个网站可以接收来自多个网站的请求.有点像升级检查.
这些网站将发送用户名,密码,应用程序版本等信息,然后我的网站将根据此信息发送回复.
基本上这是一个$_GET请求,类似于:
http://www.mysite.com/?user=boo\u0026amp;password=foo\u0026amp;version=4
我想知道是否会出现这样的安全问题.这个数据能以某种方式被“截获”吗?
解决方法:
好吧,我强烈建议不要在任何情况下(即使在SSL下)在纯文本中发送用户名/密码.相反,我建议使用摘要形式的身份验证.
相反,我建议生成一个大的身份验证令牌(一个大的随机字符串,128个字符可以工作).然后,用户将在他们的应用程序中安装此“令牌”.
现在,当应用程序检查更新时,它会首先向您的服务器发出请求摘要令牌的请求.这是一个随机的一次性使用令牌,仅用于一个请求.您的应用程序应生成令牌,将其以持久格式(文件,内存,数据库等)与时间戳一起存储,然后将其发回.
现在,您的应用程序会收到此摘要令牌(此处称为$dt).然后,使用已经提供的预配置身份验证令牌对其进行hmac.
$authBit = $username . ':' . $authToken;
$hash = hash_hmac('sha256', $authBit, $digestToken);
$authField = $username . ':' . $hash . ':' . $digestToken;
然后,您将$authField发送到服务器.然后服务器将拆分部件:
list ($user, $hash, $digestToken) = explode(':', $authField);
现在,您首先在数据库中查找用户的身份验证令牌,并将其存储在$authToken中.然后,你查找$digestToken以确保它存在并且它是在60秒前创建的(如果它太短,你可以调整它,但不要使它显着更长).无论哪种方式,此时都要从db中删除它(以防止它被重用).
现在,如果$digestToken存在且有效,并且您可以找到$authToken,那么只需执行以下检查:
$stub = $user . ':' . $authToken;
if ($hash == hash_hmac('sha256', $stub, $digestToken)) {
//valid user
} else {
//Not valid
}
它的好处是可以每次更改已发送的令牌和单个http请求(读取请求流的任何人都无法从请求中获取任何敏感信息,除了您可以进一步屏蔽的用户名,如果您愿意的话) …
android – 使用bundle将数据从一个活动传递到另一个活动 – 不在第二个活动中显示
我目前正在尝试通过REST API调用获取数据,解析它以获取我需要的信息,然后将该信息传递给新活动.我正在使用loopj.com中的异步HTTP客户端作为REST客户端,然后分别使用以下代码将onClick和onCreate用于当前和未来的活动.
Eclipse没有为我的任何代码传递任何错误,但是当我尝试在模拟器中运行时,在新活动/视图打开时我什么也得不到(即空白屏幕).我试图在我的REST CLIENT中使用不同的URL进行编码,但我仍然没有看到任何内容.我甚至通过在onClick中注释try / catch并更改bundle.putString(“VENUE_NAME”,venueName)中的venueName来取消API调用. to searchTerm.仍然,新视图出现但没有显示任何内容.什么没有通过,或者我忘记了第二个活动显示的是什么名字?
public void onClick(View view) {
Intent i = new Intent(this, ResultsView.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String searchTerm = editText.getText().toString();
//call the getFactualResults method
try {
getFactualResults(searchTerm);
} catch (JSONException e) {
// Todo Auto-generated catch block
e.printstacktrace();
}
//Create the bundle
Bundle bundle = new Bundle();
//Add your data from getFactualResults method to bundle
bundle.putString("VENUE_NAME", venueName);
//Add the bundle to the intent
i.putExtras(bundle);
//Fire the second activity
startActivity(i);
}
第二个活动中应该接收意图和捆绑并显示它的方法:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the message from the intent
//Intent intent = getIntent();
//String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
//Get the bundle
Bundle bundle = getIntent().getExtras();
//Extract the data…
String venname = bundle.getString(MainActivity.VENUE_NAME);
//Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(venname);
//set the text view as the activity layout
setContentView(textView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setdisplayHomeAsUpEnabled(true);
}
}
谢谢你的帮助.非常感谢.
解决方法:
您可以通过两种方式发送数据.这就是你现在发送它的方式.它没有任何问题.
//Create the bundle
Bundle bundle = new Bundle();
//Add your data from getFactualResults method to bundle
bundle.putString("VENUE_NAME", venueName);
//Add the bundle to the intent
i.putExtras(bundle);
startActivity(i);
但是,在您的代码(第二个Activity)中,您将Bundle中的键称为MainActivity.VENUE_NAME,但代码中没有任何内容表明您有一个类,该类返回值作为Bundle发送的实际键名.将第二个Activity中的代码更改为:
Bundle bundle = getIntent().getExtras();
//Extract the data…
String venname = bundle.getString("VENUE_NAME");
//Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(venname);
如果Bundle包含使用此密钥的密钥,您可以检入第二个Activity,并且您将知道密钥在Bundle中不存在.但是,上面的修正将使它适合您.
if (bundle.containsKey(MainActivity.VENUE_NAME)) {
....
}
android – 将数据从一个应用程序传递到另一个应用程序
参见英文答案 > launch activities from different package 4个
我有2个Android应用程序:
app1 - Activity11 --> Activity12 --> Activity13
app2 - Activity21 --> Activity22 --> Activity23
我想从一个应用程序传递到另一个应用程序的第二个活动,传递一些数据.
app1 - Activity11 -->(switch to app2)--> Activity22 --> Activity23
我要遵循哪些步骤?你知道一些教程吗?
我现在还没有编写代码,因为我不知道从哪里开始.
提前致谢.
解决方法:
你需要研究android Intents和Intent Filters. Check this training article for example.
This blog post can also be an interesting read.
发送文本的快速示例(其他类型位于顶部的链接中);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
并接受:
void onCreate (Bundle savedInstanceState) {
...
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
handleSendText(intent); // Handle text being sent
} else if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendMultipleImages(intent); // Handle multiple images being sent
}
} else {
// Handle other intents, such as being started from the home screen
}
...
}
void handleSendText(Intent intent) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// Update UI to reflect text being shared
}
}
void handleSendImage(Intent intent) {
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
// Update UI to reflect image being shared
}
}
void handleSendMultipleImages(Intent intent) {
ArrayList<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (imageUris != null) {
// Update UI to reflect multiple images being shared
}
}
您还必须更新清单:
<activity android:name=".ui.MyActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
angular – 如何将数据从一个页面传递到另一个页面,以便在Ionic 2中进行导航
这是json链接:
1. http://factoryunlock.in//products借助此链接,我将在列表中显示产品
但是现在我想展示那个特定项目的细节.所以我使用这个链接
http://factoryunlock.in/products/1
我想在特定项目的点击事件后更改该ID(在链接2产品/ 1中).
这是我的Listview代码(Second.ts).
import { Component } from '@angular/core'; import { IonicPage,NavController,NavParams } from 'ionic-angular'; import { EarthquakesProvider } from '../../providers/earthquakes/earthquakes'; import { DetailsPage } from '../details/details'; import { ChartsPage } from '../charts/charts'; @IonicPage() @Component({ selector: 'page-second',templateUrl: 'second.html',providers: [EarthquakesProvider] }) export class SecondPage { public DateList: Array<Object>; constructor(public _navCtrl: NavController,public _earthquakes: EarthquakesProvider) { this.getEarthquakes(); } public Listitem(l) { this._navCtrl.push(DetailsPage ); } public openModal() { this._navCtrl.push(ChartsPage); } getEarthquakes() { this._earthquakes.loadEarthquakess().subscribe(res => { this.DateList = res.data; }); } }
这是我的提供者控制器:
import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; @Injectable() export class EarthquakesProvider { constructor(public _http: Http) { console.log('Hello Earthquakes Provider'); } loadEarthquakess() { return this._http.get('http://factoryunlock.in/sundar/public/api/v1/products') .map(res => res.json()); } loadEarthquakesdetails() { return this._http.get('http://factoryunlock.in/sundar/public/api/v1/products/1') .map(res => res.json()); }
这是我的details.ts代码
import { Component } from '@angular/core'; import { IonicPage,NavParams } from 'ionic-angular'; import { EarthquakesProvider } from '../../providers/earthquakes/earthquakes'; @IonicPage() @Component({ selector: 'page-details',templateUrl: 'details.html',providers: [EarthquakesProvider] }) export class DetailsPage { public DateList: Array<Object>; item: any; constructor(public _navCtrl: NavController,public _earthquakes: EarthquakesProvider) { this.getEarthquakes(); } getEarthquakes() { this._earthquakes.loadEarthquakesdetails().subscribe(res => { this.DateList = res.data; console.log(res.data); }); } }
这是我的详细信息视图快照
public Listitem(id) { this._navCtrl.push(DetailsPage,{id: id}); }
提供者控制者
loadEarthquakesdetails(id) { return this._http.get(`http://factoryunlock.in/sundar/public/api/v1/products/${id}`) .map(res => res.json()); }
Details.ts代码
import { Component } from '@angular/core'; import { IonicPage,providers: [EarthquakesProvider] }) export class DetailsPage { public DateList: Array<Object>; item: any; id: number; constructor(public _navCtrl: NavController,public _earthquakes: EarthquakesProvider,public navParams: NavParams) { this.id = navParams.get('id'); } ionViewDidLoad() { this.getEarthquakes(this.id); } getEarthquakes(id) { this._earthquakes.loadEarthquakesdetails(id).subscribe(res => { this.DateList = res.data; console.log(res.data); }); } }
angularjs – 将数据从一个指令传递到另一个指令
-------------- -------------- | directive 1 |---data-->| directive 2 | | | | | --------------- --------------
解决方法
在第一个指令:
$rootScope.$broadcast("NEW_EVENT",data);
在另一个指令:
scope.$on("NEW_EVENT",function(event,data){ //use the data });
看看这个Understanding Angular’s $scope and $rootScope event system $emit,$broadcast and $on
今天的关于PHP – 安全地将数据从站点传递到另一个站点和php提交数据到另一个php的分享已经结束,谢谢您的关注,如果想了解更多关于android – 使用bundle将数据从一个活动传递到另一个活动 – 不在第二个活动中显示、android – 将数据从一个应用程序传递到另一个应用程序、angular – 如何将数据从一个页面传递到另一个页面,以便在Ionic 2中进行导航、angularjs – 将数据从一个指令传递到另一个指令的相关知识,请在本站进行查询。
本文标签: